Running ProGuard in my Android Studio Project I get warnings like this:
Warning: com.google.common.collect.Maps: can't find referenced class javax.annotation.Nullable
I might solve this with one of this variants:
1
-keep class com.google.common.collect.** { *; }
-dontwarn com.google.common.collect.**
2
-keep class javax.annotation.** { *; }
-dontwarn javax.annotation.**
What is the best way to solve the above warning? What is the difference between variant 1. and 2.?
-keepclassmembernames. This is the most permissive keep directive; it lets ProGuard do almost all of its work. Unused classes are removed, the remaining classes are renamed, unused members of those classes are removed, but then the remaining members keep their original names.
If your code works fine without the missing classes, you can suppress the warnings with '-dontwarn' options. ( http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass) Warning: there were 2 unresolved references to program class members. Your input classes appear to be inconsistent.
Code shrinking with R8 is enabled by default when you set the minifyEnabled property to true .
consumerProguardFiles 'consumer-rules.pro'} A consumer proguard rules file is like any other proguard rules files with the caveat that the rules inside it are automatically applied to the consuming application when the application is being built in a proguard enabled mode.
This is the most common error beacuse of "many pre-compiled third-party libraries refer to other libraries that are not actually used and therefore not present. This works fine in debug builds, but in release builds, ProGuard expects all libraries, so it can perform a proper static analysis."
From: http://proguard.sourceforge.net/index.html#manual/examples.html
So,this javax.annotation.Nullable
might not be there in your project but the libraries you are using has some classes who are internally referring to them.
However you can avoid these warnings by -dontwarn javax.annotation.**
or --dontwarn com.google.common.collect.**
. But I dont think -keep class javax.annotation.** { *; }
and looks illogical.
So, if you do -keep class com.google.common.collect.** { *; }
you skip this package from all 3 steps of Proguard
execution (Shrinking,optimization and obfuscation) which makes sense according to my understanding.
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