I upgraded to Android Studio 2.0 Beta 5. I'm using gradle tools 2.0.0-beta5. On the Android dev blogspot site, there is a video explaining how to use the new Shrinker for debug builds (at 3:14)
https://www.youtube.com/watch?list=PLWz5rJ2EKKc_w6fodMGrA1_tsI3pqPbqa&v=xxx3Fn7EowU
I'm trying to build my project with the debug buildType as explained in the video:
debug {
minifyEnabled true
useProguard false
}
I'm getting a bunch of warnings and then this this error when building:
Error:Execution failed for task 'app:transformClassesWithNewClassShrinkerForMyAppNameGoesHereDebug'.
Warnings found during shrinking, please use -dontwarn or -ignorewarnings to suppress them.
With Proguard, I would add the appropriate -dontwarn necessary in the proguard project file. Is there a Shrinker project file somewhere that I can add -dontwarn statements?
Code shrinking (or tree-shaking): detects and safely removes unused classes, fields, methods, and attributes from your app and its library dependencies (making it a valuable tool for working around the 64k reference limit).
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.
minify is an Android tool that will decrease the size of your application when you go to build it. It's extremely useful as it means smaller apk files! It detects any code or libraries that aren't being used and ignores them from your final apk.
To enable R8 shrinking in your application, set the minifyEnabled to true in your app's main build. gradle file.
I found some documentation on this. Turns out it uses the same configuration files as Proguard. Here is the relevant part from the doc:
The built-in shrinker can only remove dead code, it does not obfuscate or optimize. It can be configured using the same files as ProGuard, but will ignore all flags related to obfuscation or optimization. Unlike ProGuard, we support using the built-in shrinker together with Instant Run.
Also, here is a sample configuration for reference:
buildTypes {
debug {
minifyEnabled true
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
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