Error:Execution failed for task ':app:packageRelease'. > Unable to compute hash of /../AndroidStudioProjects/../classes.jar

后端 未结 7 2045
天涯浪人
天涯浪人 2020-11-28 11:11

I\'m trying to do a \'release\' build on an Android app and I keep on getting this error of:

Unable to compute hash of /../AndroidStudioProjects/../cl

相关标签:
7条回答
  • 2020-11-28 11:27

    I know this is an old question but maybe this answer works for someone. I added -dontwarn butterknife.** to proguard then gradle builds properly.

    0 讨论(0)
  • 2020-11-28 11:30

    I know there's already an answer here, but my situation was a little different, and I wanted to share it.

    For me, my project's proguard file, namely, proguard-rules.pro, was somehow renamed to proguard-android.txt.

    The proguard-android.txt is reserved for Android's default proguard rules, so essentially, I was overriding Android's proguard file, which was causing havoc, and I would get the Unable to compute hash message.

    Once I changed the filename in my project from proguard-android.txt to proguard-rules.pro I was able to get things working.

    0 讨论(0)
  • 2020-11-28 11:30

    Disabling the minifyEnabled option from my gradle file corrected the error in my build.

    build.gradle

    buildTypes {
           release {
                  // DISABLE OPTION
                  //minifyEnabled true
                  proguardFiles 'proguard.cfg'
           }
    }
    
    0 讨论(0)
  • 2020-11-28 11:32

    For me the following 2 lines inside proguard.cfg helped:

     -keep class com.google.android.gms.** { *; }
     -dontwarn com.google.android.gms.**
    
    0 讨论(0)
  • All the current answers to this question are just giving the Proguard rules that worked for them, every fix will be different. First off, confirm it's a Proguard problem by checking that the classes-proguard directory is somewhere in the error message, something like this: Unable to compute hash of /Users/Documents/projectX/app/build/intermediates/classes-proguard/release/classes.jar

    This means it's caused by an earlier Proguard error so you need to scroll up in the Messages window or Gradle Console window and check what warnings or errors you're getting. Just as an example, in my current project, Square's Picasso library is causing the error: Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient. I just added -dontwarn com.squareup.okhttp.** to ignore the warnings, and the app still worked as normal.

    A lot of the Proguard errors will be warnings about some class so just adding -dontwarn for whatever class is causing it in your project often works.

    I know the StackOverflow way is just Google the error message, copy and paste the top answer and hope for the best but here you've to understand it a bit and figure out the proguard rules for you!

    0 讨论(0)
  • 2020-11-28 11:39

    Just create a file proguard-rules.pro and add "-dontwarn package names" that gave you warning on the message.

    0 讨论(0)
提交回复
热议问题