Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't generate signed APK from Android studio "Execution failed for task ':packageRelease'"

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!

like image 679
김재형 Avatar asked Jun 19 '15 09:06

김재형


3 Answers

Just add to the project's proguard-rules:

-keep public class com.google.android.gms.**
-dontwarn com.google.android.gms.**
like image 54
Artemiy Avatar answered Nov 18 '22 02:11

Artemiy


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.** { *; }
like image 36
김재형 Avatar answered Nov 18 '22 02:11

김재형


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

like image 6
Lakedaemon Avatar answered Nov 18 '22 03:11

Lakedaemon