Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When using R8 on Android, do I need to uninstall my existing Proguard?

Do I need to remove Proguard related code from Gradle when using R8?

minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
like image 629
dylan.kwon Avatar asked Jan 30 '19 05:01

dylan.kwon


People also ask

What is the difference between ProGuard and R8?

R8 differs from proguard in the following ways: R8 has higher Kotlin language support as compared to proguard. Proguard is mainly used by applications developed using Java. Usually, the R8 compiler is much faster than the proguard compiler.

How do I enable R8 on my Android?

To enable R8 shrinking in your application, set the minifyEnabled to true in your app's main build. gradle file.

Is ProGuard necessary for Android?

It reduces the size of the application. It removes the unused classes and methods that contribute to the 64K method counts limit of an Android application. It makes the application difficult to reverse engineer by obfuscating the code.

How does ProGuard work in Android?

In summary, ProGuard has the following effect on our project: It shrinks the application's size. It removes unused classes and methods that contribute to an Android application's 64K method count limit. By obfuscating the code, it makes it difficult to reverse engineer the application.


1 Answers

You don't actually remove the proguard rules, as R8 works with Proguard rules in compat mode. For more details, please refer to https://android-developers.googleblog.com/2018/11/r8-new-code-shrinker-from-google-is.html.

R8 is available with Android Studio 3.3 beta and works with Proguard rules. To try it, set the following in your project's gradle.properties file:

android.enableR8=true

But for the full mode, it is not directly compatible with Proguard.


Edit #1

Check here for how to migrate Proguard to R8: Android/java: Transition / Migration from ProGuard to R8?

like image 162
shizhen Avatar answered Oct 07 '22 15:10

shizhen