What is R8?
R8 is another tool that will convert your java byte code into an optimized format of dex code. It will check the whole application and will remove the unused classes and methods. It helps us to reduce the size of our APK and to make our app more secure. R8 uses similar proguard rules to modify its default behavior.
How to enable R8 in your Application?
R8 is already present in your application you just have to enable it. To enable it just Navigate to the Gradle Scripts > build.gradle(:app) and then you will get to see a method called buildTypes.
buildTypes {
release {
minifyEnabled true
}
}
In this block of code, we have to change minifyEnabled to true to activate R8. This code for R8 is written under the release block which is only working on the release build of your APK.
Difference Between Proguard and R8 in Android
Proguard and R8 both are similar tools that are used for reducing the size of our APK and increase the performance of our APK by shrinking the unused resources. In this article, we will take a look at:
- What is Proguard?
- What is R8?
- Difference between Proguard and R8.
Contact Us