Gradle Build Failure
Solution 1
I also had this issue when upgrading everything that is built related to 23 (Android Libraries, SDK etc).
This proguard configuration fixed it for me:
-dontwarn org.apache.http.**
-dontwarn android.net.http.AndroidHttpClient
-dontwarn com.google.android.gms.**
-dontwarn com.android.volley.toolbox.**
Solution 2
Turns out I had omitted the getDefaultProguardFile('proguard-android.txt')
line on the proguard files and was just using proguard-rules.pro
Solution 3
added these two line in progaurd
-dontwarn android.net.http.AndroidHttpClient
-dontwarn com.google.android.gms.**
and it works..
It is related to library used in project.
Solution 4
The default ProGuard file already has a rule to ignore support library warnings. If you don't have it you can add to your file
-dontwarn android.support.**
but would be better to add the default one. See Proguard configuration@Android Developers
Solution 5
This also could happen due to errors/warnings related to included .jar files Check in build output for proguard warnings/errors.
I had issue related to opencsv jar file. Hint by Lakedaemon in above comment helped me and its solved.
Alex Kombo
Updated on July 17, 2020Comments
-
Alex Kombo almost 4 years
My project compiles and executes well on debug mode but when i try to generate a signed apk, errors arise. This appears on the message log:
:app:proguardRelease Warning:android.support.v4.app.DialogFragment: can't find referenced class android.support.v4.app.DialogFragment$DialogStyle Warning:android.support.v4.app.FragmentTransaction: can't find referenced class android.support.v4.app.FragmentTransaction$Transit Warning:android.support.v4.view.ViewCompat: can't find referenced class android.support.v4.view.ViewCompat$ResolvedLayoutDirectionMode Warning:android.support.v4.view.ViewCompat: can't find referenced class android.support.v4.view.ViewCompat$LayoutDirectionMode Warning:android.support.v4.view.ViewCompat: can't find referenced class android.support.v4.view.ViewCompat$LayerType Warning:android.support.v4.view.ViewCompat: can't find referenced class android.support.v4.view.ViewCompat$AccessibilityLiveRegion Warning:android.support.v4.view.ViewCompat: can't find referenced class android.support.v4.view.ViewCompat$ImportantForAccessibility Warning:android.support.v4.view.ViewCompat: can't find referenced class android.support.v4.view.ViewCompat$OverScroll Warning:android.support.v4.widget.DrawerLayout: can't find referenced class android.support.v4.widget.DrawerLayout$EdgeGravity Warning:android.support.v4.widget.DrawerLayout: can't find referenced class android.support.v4.widget.DrawerLayout$LockMode Warning:android.support.v4.widget.DrawerLayout: can't find referenced class android.support.v4.widget.DrawerLayout$State Warning:there were 11 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. (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass) Exception while processing task java.io.IOException: Please correct the above warnings first. at proguard.Initializer.execute(Initializer.java:473) at proguard.ProGuard.initialize(ProGuard.java:233) at proguard.ProGuard.execute(ProGuard.java:98) at proguard.gradle.ProGuardTask.proguard(ProGuardTask.java:1074) at com.android.build.gradle.tasks.AndroidProGuardTask.doMinification(AndroidProGuardTask.java:139) at com.android.build.gradle.tasks.AndroidProGuardTask$1.run(AndroidProGuardTask.java:115) at com.android.builder.tasks.Job.runTask(Job.java:48) at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41) at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:227) at java.lang.Thread.run(Thread.java:745) :app:dexRelease UP-TO-DATE :app:crashlyticsStoreDeobsRelease :app:crashlyticsUploadDeobsRelease :app:validateExternalOverrideSigning :app:packageRelease FAILED Error:Execution failed for task ':app:packageRelease'. > Unable to compute hash of /home/kombo/RAL/Mpasho/app/build/intermediates/classes-proguard/release/classes.jar
I have tried every possible way of remedying this by updating my build tools, using the latest gradle version, checking all the dependencies and the error still shows up.
I am pretty sure the v4 support library is present in the project since no errors arise in debug mode.
-
Alex Kombo about 9 yearsThat only gets me as far as removing the warnings. But this error still persists,
Error:Execution failed for task ':app:packageRelease'. > Unable to compute hash of /home/kombo/RAL/Mpasho/app/build/intermediates/classes-proguard/release/classes.jar
-
Lakedaemon almost 9 yearsI had the same problem. Cleaning, clearing caches didn't resolve it. When I looked higher in the build log, I noticed that proguard was spouting some warnings. I probably had 2 libraries that were sharing some code (duplicate classes..) I removed one of the offending library and it fixed my proguard issue --> look at your build output for proguard warnings/errors
-
Brill Pappin almost 9 yearsSame problem... no solution.
-
Niklas almost 9 years@dangalg checkout my answer
-
Diego Palomar over 8 yearsThis is very frustrating, I have tried almost everything and I can not fix it :$
-
justadev over 8 yearsGood find. This was it.
-
Roon13 over 8 yearsWorked for me too!! after 3 hrs of searching!! Thanks a lot sir!!
-
Ahmed over 8 yearsSame problem, no solution yet
-
Niklas over 8 years@Ahmed in your proguard configuration file
-
GuilhE over 8 yearsNot working for me: stackoverflow.com/questions/35804397/proguard-and-apache-legacy
-
IgorGanapolsky about 8 yearsThis is assuming people are using volley.
-
Nativ about 8 yearsso you are not using proguard at all mate. try to decompile you apk and see that you get the exact project files
-
Bolein95 about 7 yearsThanks! You saved my day
-
Ivan Leong over 6 yearsThis is not a solution is you need pro-guard enabled