简体   繁体   English

错误:任务 ':app:packageRelease' 的执行失败。 > 无法计算 /../AndroidStudioProjects/../classes.jar 的哈希值

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

I'm trying to do a 'release' build on an Android app and I keep on getting this error of:我正在尝试在 Android 应用程序上进行“发布”构建,但不断收到以下错误:

Unable to compute hash of /../AndroidStudioProjects/../classes.jar无法计算 /../AndroidStudioProjects/../classes.jar 的哈希值

And then when I look into that directory for 'classes.jar' the file isn't there.然后当我查看该目录中的“classes.jar”时,该文件不存在。 Do I have to create this file myself with a gradle task?我必须自己用 gradle 任务创建这个文件吗?

There's something going on with proguard here but it's not giving much useful information other than 'Unable to compute hash...."这里有一些 proguard 发生了一些事情,但除了“无法计算哈希......”之外,它没有提供太多有用的信息。

Here's my gradle.build file:这是我的 gradle.build 文件:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    defaultConfig {
        applicationId "com.example"
        minSdkVersion 11
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        debug {
            buildConfigField "String", "SERVER_URL", '"http://10.0.2.2:3000"'
        }
        release {
            buildConfigField "String", "SERVER_URL", '"https://example.com"'
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debugRelease {
            buildConfigField "String", "SERVER_URL", '"https://example.com"'
            debuggable true
            jniDebuggable false
            renderscriptDebuggable false
            minifyEnabled false
            zipAlignEnabled true
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.android.support:recyclerview-v7:22.1.1'
    compile 'com.android.support:cardview-v7:22.1.1'
    compile 'com.google.android.gms:play-services-gcm:7.5.0'
}

If someone could help me debug this issue that'd be great.如果有人能帮我调试这个问题,那就太好了。

All the current answers to this question are just giving the Proguard rules that worked for them, every fix will be different.这个问题的所有当前答案只是给出了适用于他们的 Proguard 规则,每次修复都会有所不同。 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首先,通过检查 classes-proguard 目录是否在错误消息中的某处来确认这是一个 Proguard 问题,如下所示: 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.这意味着它是由早期的 Proguard 错误引起的,因此您需要在 Messages 窗口或 Gradle Console 窗口中向上滚动并检查您收到哪些警告或错误。 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 .举个例子,在我当前的项目中,Square 的 Picasso 库导致错误: 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.我刚刚添加了-dontwarn com.squareup.okhttp.**以忽略警告,该应用程序仍然正常工作。

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.许多 Proguard 错误都是关于某个类的警告,因此只需为项目中导致它的任何类添加 -dontwarn 就可以了。

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!我知道 StackOverflow 的方式只是谷歌的错误信息,复制并粘贴最重要的答案并希望得到最好的但在这里你必须理解它并为你找出 proguard 规则!

I figured out the problem:我解决了这个问题:

Open up the proguard-rules.pro for your project and add this to the bottom:打开项目的proguard-rules.pro并将其添加到底部:

-dontwarn java.nio.file.Files
-dontwarn java.nio.file.Path
-dontwarn java.nio.file.OpenOption
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

Basically how I solved it was this I tried to run my app in 'release' mode and got a bunch of errors similar to this guy here: https://github.com/square/okio/issues/144基本上我是如何解决这个问题的,我试图在“发布”模式下运行我的应用程序,但遇到了一堆类似于这里的人的错误: https : //github.com/square/okio/issues/144

I pretty much followed what he said and fixed it.我几乎按照他说的去做并修复了它。

Hope this can help others with generating their APK's!希望这可以帮助其他人生成他们的 APK!

For me the following 2 lines inside proguard.cfg helped:对我来说, proguard.cfg 中的以下两行有帮助:

 -keep class com.google.android.gms.** { *; }
 -dontwarn com.google.android.gms.**

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 .对我来说,我的项目的 proguard 文件,即proguard-rules.pro ,以某种方式被重命名为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 . proguard-android.txt是为 Android 的默认 proguard 规则保留的,所以基本上,我覆盖了 Android 的 proguard 文件,这造成了严重破坏,我会得到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.一旦我将项目中的文件名从proguard-android.txt更改为proguard-rules.pro我就可以开始工作了。

I know this is an old question but maybe this answer works for someone.我知道这是一个老问题,但也许这个答案对某人有用。 I added -dontwarn butterknife.** to proguard then gradle builds properly.我添加了-dontwarn butterknife.**来 proguard 然后 gradle 正确构建。

For me, it is showing the same error i solved it make sure you have the correct Keystore password in file对我来说,它显示了与我解决的相同的错误,请确保您在文件中拥有正确的密钥库密码

\mobile\android\gradle.properties 
MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore
MYAPP_UPLOAD_KEY_ALIAS=my-key-alias
MYAPP_UPLOAD_STORE_PASSWORD=yourpassword
MYAPP_UPLOAD_KEY_PASSWORD=yourpassword

只需创建一个文件 proguard-rules.pro 并添加“-dontwarn package names”,在消息中向您发出警告。

Disabling the minifyEnabled option from my gradle file corrected the error in my build.从我的 gradle 文件中禁用minifyEnabled选项更正了我的构建中的错误。

build.gradle构建.gradle

buildTypes {
       release {
              // DISABLE OPTION
              //minifyEnabled true
              proguardFiles 'proguard.cfg'
       }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:执行…':app:packageRelease'。>无法计算.. \\ app \\ build \\ intermediates \\ classes-proguard \\ .. \\ release \\ classes.jar的哈希 - Error:Execution… ':app:packageRelease'.> Unable to compute hash of ..\app\build\intermediates\classes-proguard\..\release\classes.jar Android Studio,ProGuard无法计算Classes.jar的哈希值 - Android Studio, ProGuard unable to compute hash of Classes.jar Android linphone.jar错误:任务':app:dexDebug'的执行失败 - Android linphone.jar Error:Execution failed for task ':app:dexDebug' 任务':app:packageRelease'的执行失败,无法从存储“ C:\\ Users \\”中读取密钥key0:密钥库被篡改,或者密码不正确 - Execution failed for task ':app:packageRelease' Failed to read key key0 from store “C:\Users\”: Keystore was tampered with, or password was incorrect 在启用ProGuard的情况下,Gradle构建失败,缺少classes.jar - Gradle Build failed with ProGuard enabled, missing classes.jar Gradle Cmdline错误,任务':..:jar'的执行失败 - Gradle Cmdline error, Execution failed for task ':..:jar' 执行Maven时找不到Java classes.jar'错误 - Java classes.jar' could not be found error when executing maven Intellij构建错误:任务':classes'的执行失败,@ NotNull检测失败 - Intellij build error: Execution failed for task ':classes' @NotNull instrumentation failed 错误:任务“:app:transformClassesWithMultidexlistForDebug”的执行失败 - Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug' 错误:运行时任务 ':app:dexDebug' 执行失败 - Error:Execution failed for task ':app:dexDebug' at runtime
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM