Hello,
Switching to Guava 20.0 as suggested in Android Studio make release build failed when it's done with Proguard shrinkRessources or/and minifyEnabled enabled.
Rollback to Guava 18.0 "solves" it.
Warning: com.google.common.util.concurrent.FuturesGetChecked$GetCheckedTypeValidatorHolder$ClassValueValidator$1: can't find superclass or interface java.lang.ClassValue
Warning: com.google.common.base.AbstractIterator: can't find referenced class com.google.errorprone.annotations.CanIgnoreReturnValue
(...)
Warning: there were 696 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with '-dontwarn' options.
Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
:app:transformClassesAndResourcesWithProguardForRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> Job failed, see logs for details
Android Studio 2.3.3
Gradle 3.3
Proguard 4.7
JRE1.8.0_122
Thanks,
Eric
@eldk Have you tried updating to the latest version of guava-android (23.0, I believe) instead? :)
(You can find the Maven/Gradle co-ordinates for guava-android at https://search.maven.org/#artifactdetails%7Ccom.google.guava%7Cguava%7C23.0-android%7Cbundle).
I have tryed with Guava 19.0 and 23.0-android with same result as 20.0 : Proguard complains about unresolved dependencies. Less warning for 23.0-android.
Thanks for letting me know the results of applying 23.0-android @eldk! This is out of my league now unfortunately, so let's wait for someone from the Guava team to reply.
Thanks @jbduncan
We need to publish our Proguard configurations someday (https://github.com/google/guava/issues/2117). For this particular problem, you can add:
-dontwarn java.lang.ClassValue
(We have a fallback for systems on which ClassValue isn't available.)
Hello,
With :
-dontwarn java.lang.ClassValue
Proguard (4.7) still throws errors.
In #2117 the link to that topic https://stackoverflow.com/questions/9120338/proguard-configuration-for-guava-with-obfuscation-and-optimization gives the solution for Guava 20.0 .
-dontwarn com.google.common.base.**
-keep class com.google.common.base.** {*;}
-dontwarn com.google.errorprone.annotations.**
-keep class com.google.errorprone.annotations.** {*;}
-dontwarn com.google.j2objc.annotations.**
-keep class com.google.j2objc.annotations.** { *; }
-dontwarn java.lang.ClassValue
-keep class java.lang.ClassValue { *; }
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-keep class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement { *; }
Thanks @cpovirk , @breyed, @gengjiawen
Eric
Those rules are vastly overly keep-y. Why are you suppressing warnings and
then also keeping for each?
On Mon, Aug 28, 2017 at 3:32 PM eldk notifications@github.com wrote:
Hello,
With :
-dontwarn java.lang.ClassValue
Proguard (4.7) still throw errors.In #2117 https://github.com/google/guava/issues/2117 the link to that
topic
https://stackoverflow.com/questions/9120338/proguard-configuration-for-guava-with-obfuscation-and-optimization
gives the solution for Guava 20.0 .-dontwarn com.google.common.base.*
-keep class com.google.common.base.* {;}
-dontwarn com.google.errorprone.annotations.*
-keep class com.google.errorprone.annotations.* {;}
-dontwarn com.google.j2objc.annotations.*
-keep class com.google.j2objc.annotations.* { *; }
-dontwarn java.lang.ClassValue
-keep class java.lang.ClassValue { *; }
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-keep class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement { *; }Thanks @cpovirk https://github.com/cpovirk , @breyed
https://github.com/breyed, @gengjiawen https://github.com/gengjiawenEric
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/google/guava/issues/2926#issuecomment-325455128, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAEEEd066G4sdYg6jNJBXp_KKzdvtGQIks5scxWwgaJpZM4PDKt0
.
@JakeWharton
Hello,
You are right, -keep are not needed.
I will spend more time on it.
https://www.guardsquare.com/en/proguard/manual/troubleshooting#unresolvedclass
With -keep at right, without to left :

With -keep up, without down :

Thanks,
Eric
I'm a bit confused (maybe because my understanding is not complete): why are all the "keep"s unnecessary?
My feeling is that only those can be safely removed (i.e. have fallback) should not be "keep"(-ed), but the only one with fallback is sun.misc.Unsafe.
Why don't we need to keep others, e.g. java.lang.ClassValue or even com.google.common.base.**? Doesn't -dontwarn just supress the warning but still removes these classes (so that these classes will not be in the compiled file (.apk), and will cause errors like "ClassNotFound")?
Most helpful comment
I'm a bit confused (maybe because my understanding is not complete): why are all the "keep"s unnecessary?
My feeling is that only those can be safely removed (i.e. have fallback) should not be "keep"(-ed), but the only one with fallback is
sun.misc.Unsafe.Why don't we need to keep others, e.g.
java.lang.ClassValueor evencom.google.common.base.**? Doesn't-dontwarnjust supress the warning but still removes these classes (so that these classes will not be in the compiled file (.apk), and will cause errors like "ClassNotFound")?