Reputation: 479
I am using Android Studio 1.2.2 and tried to generate APK with proguard setting. But I can't do it and got below error message.
"Execution failed for task ':packageRelease'.
Unable to compute hash of /Users/Documents/projectX/app/build/intermediates/classes-proguard/release/classes.jar "
The proguard setting is just simple.
-dontshrink
-dontoptimize
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
And the gradle file is below.
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion "Google Inc.:Google APIs:22"
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.bientus.cirque.sansotong"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
// multiDexEnabled true
}
buildTypes {
debug {
debuggable true
}
release {
minifyEnabled true
//proguardFiles 'proguard-project.txt', 'proguard.cfg'
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt', 'proguard.cfg'
proguardFiles 'proguard-project.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile "com.google.android.gms:play-services:7.5.0"
// compile 'com.android.support:multidex:1.0.0'
}
buildscript {
repositories {
// mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.google.gms:google-services:1.3.0-beta1'
}
}
Can anybody give any idea or thought? Thank you very much!
Upvotes: 32
Views: 19999
Reputation: 678
I had the problem too and the best way to solve it is: Go to the gradle console and see where there is a warning e.g
Warning: com.squareup.picasso.OkHttpDownloader: can't find referenced class com.squareup.okhttp.OkHttpClient
Now open the proguard rules file and scroll to the bottom and add the line
-dontwarn com.squareup.okhttp.**
For any missing classes that you find on the gradle console you basically add the line
-dontwarn followed by class name
Hope this works for everyone too. Good luck!
Upvotes: 2
Reputation: 41
OK! its very easy ! just following step by step: build.gradle :minifyEnabled false -> minifyEnabled true proguard-rules.pro : you have to add third libraries that you use in your project like piccaso and etc. if you do this in android studio , it decline this files.
-dontwarn android.support.**
-dontwarn com.github.**
-dontwarn com.squareup.picasso.**
-dontwarn com.etsy.android.grid.**
it works :)
Upvotes: 4
Reputation: 2792
Just add to the project's proguard-rules:
-keep public class com.google.android.gms.**
-dontwarn com.google.android.gms.**
Upvotes: 17
Reputation: 479
It worked after setting followings in 'proguard-project.txt'. Obviously the gradle should be set for this file.
-dontwarn android.support.v7.**
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }
Upvotes: 11
Reputation: 841
Look at your build output. You might have proguard warnings in there, like if you have 2 libraries that share some class (with potentialy different versions).
This might prevent proguard to compute an hash.
I had the same issue while having both openIAB and opfIAB (both use Amazon and google IAB) in my build. Removing one of these libs resolved my issue
Upvotes: 6