question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Switching to guava 20.0 make Proguard fails when shrink and minify

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
renyuneyuncommented, Nov 18, 2017

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”)?

2reactions
JakeWhartoncommented, Aug 28, 2017

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/gengjiawen

Eric

— 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 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Volley always fails with Proguard - Stack Overflow
Usual builds without minification work fine. But when minifyEnabled is switched to true, everything compiles too, but all Volley requests fail ...
Read more >
Shrink, obfuscate, and optimize your app - Android Developers
To make your app as small as possible, you should enable shrinking in your release build to remove unused code and resources. When...
Read more >
Effective ProGuard keep rules for smaller applications (Google ...
ProGuard keep rules are the super power in reducing application size. Correctly specified, they allow tools to remove unneeded code and ...
Read more >
ProGuard Manual: Troubleshooting - Guardsquare
If ProGuard is not keeping the right classes or class members, make sure you are using fully qualified class names. If the package...
Read more >
Importance of Proguard for the Android platform and its ...
Sometimes the app crashes in release build even when the app is running fine in debug build. It might be an issue with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found