I upgraded my Android Studio to 3.4 earlier today, and I am using the default shrinker R8 for the first time. I copied the contents of proguard-project.txt
of a library project to its proguard-rules.pro
. proguard-project.txt
worked flawlessly for this project that generates an aar file for use by other app projects.
File proguard-rules.pro
does not seem to be used. The project has the following in its build.gradle
:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules.pro'
signingConfig signingConfigs.Release
}
debug {
signingConfig signingConfigs.Debug
}
}
proguard-rules.pro
has the following:
# Preserve all public classes, and their public and protected fields and methods.
-keep public class * {
public protected *;
}
The public methods' names are not preserved at all:
Could anyone offer a tip on how to fix this?
January 11, 2022. R8 is a tool that is used to shrink, secure, and optimize Android applications. It uses proguard rules to change the behavior of application.
To enable R8 shrinking in your application, set the minifyEnabled to true in your app's main build. gradle file.
You can add it yourself: put the proguard-rules. txt file into the app directory. It's already added to your build. gradle file so no further actions required.
Add this line to gradle.properties
android.enableR8 = true
And try below code inside your proguard-rules.pro
-keep public class ** {
public *;
protected *;
}
Edit #1
Check here for how to migrate Proguard to R8: Android/java: Transition / Migration from ProGuard to R8?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With