Home / Companies / LogRocket / Blog / Post Details
Content Deep Dive

A guide to R8 and code shrinking in Android

Blog post from LogRocket

Post Details
Company
Date Published
Author
Anvith Bhat
Word Count
1,989
Company Posts That Month
104
Language
-
Hacker News Points
-
Post removed?
No
Summary

Code shrinking and obfuscation are crucial strategies for optimizing Android apps by reducing their size and protecting them from reverse engineering. The shift from Proguard to the R8 compiler has provided enhanced functionalities, including better support for Kotlin and more efficient code inlining. R8 follows multiple stages to shrink and optimize code, such as desugaring, resource shrinking, and obfuscation, and finally converts bytecode into dexcode. Configuring code shrinking involves setting flags in the build.gradle file, and users can define specific rules using Proguard-style schemas to retain necessary code and resources. Debugging in R8 can be managed with tools like retrace and printusage, while aggressive shrinking can be enabled for more rigorous optimizations. Overall, understanding and utilizing R8 can significantly enhance app performance by reducing APK size and improving security.

Trends Found in this Post

No tracked trend matches for this post yet.

Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.