


It also disposes dead code that may be present. R8 will check, rewrite, and rearrange your code to improve code efficiency. When you shrink your app, you optimize your code. Such an application will be very large before being shrunk. Keep in mind that you also may have used some other libraries such as the Androidx libraries, Jetpack library, and Google Play Services. This obviously makes your app very large. This will include the unused methods and functions within that library.įor example, when you create an application in Kotlin, your app will carry the whole Kotlin-stdlib. When you don’t shrink your app, all 3rd party libraries that you included in your app will take some space in it. Also, it removes all resources that you added to your project but were never used. Enabling it to your project will remove all unused classes, functions, and variables.

fullMode = true How is R8 used to shrink, optimize and secure Android applications?Īs we mentioned, R8 is used to shrink applications before being released to the play store for users to access. To enable R8, open adle module app file and add this piece of code inside the buildTypes.Īndroid. Enabling R8 in your projectīy default, R8 is present in Android Studio. NOTE: For gradle version 3.4.0 or higher, R8 uses the proguard rules which are already predefined. It can shrink an app by 10%, whereas proguard can cut it by 8%.

Building to release version of an application.Īs mentioned earlier, R8 is a tool that is used to shrink, secure, and optimize Android applications.Techniques used by R8 to do application Shrinking.How R8 is used to shrink, optimize and secure Android applications.Goalsīy the end of this tutorial, you should have an understanding of the following: Later in this tutorial, we will see how the two differ from each other. They are similar but have some slight differences. It uses proguard rules to change the behavior of application.ĭevelopers tend to confuse R8 with proguard. R8 is a tool that is used to shrink, secure, and optimize Android applications.
