transformClassesAndResourcesWithProguardForRelease FAILED

I am trying to Build my Android application with Gradle in console. But getting below error about task ':app:transformClassesAndResourcesWithProguardForRelease':

build.gradle:

buildscript {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app/build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion '24.0.2'
    defaultConfig {
        applicationId "com.XXX.XXX"
        minSdkVersion 14
        targetSdkVersion 24
        versionCode 1
        versionName "0.1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    'proguard-rules.pro'
        }
    }
}


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile('com.squareup.retrofit2:retrofit:2.1.0') {
        exclude module: 'okhttp'
    }
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.squareup.retrofit2:converter-moshi:2.1.0'
    compile 'moe.banana:moshi-jsonapi:2.2.0'
    compile 'com.squareup.moshi:moshi-adapters:1.3.1'
    compile 'com.google.android.gms:play-services-maps:9.6.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.firebase:firebase-core:9.6.0'
    compile 'com.google.firebase:firebase-crash:9.6.0'
    testCompile 'junit:junit:4.12'
}

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

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

./gradlew build --stacktrace

This is the exception I am receiving:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task
':app:transformClassesAndResourcesWithProguardForRelease'.

Solution 1:

Try adding this code to your proGuard rules, it worked for me

-ignorewarnings
-keep class * {
    public private *;
}

The answer was posted here: Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease

Solution 2:

add this code to ..your-project/app/proguard-rules.pro

 -ignorewarnings

your signed apk will be generated successfully...

Update :

That's better to fix your warning messages using -dontwarn or -keep keys on your proguard-rules.pro... Because if you use (maybe your libraries) java reflection in your code the application will be crashed...

Solution 3:

It worked for me I also had to add following in a pro-gaurd.txt file

#### -- Picasso --
 -dontwarn com.squareup.picasso.**

 #### -- OkHttp --

 -dontwarn com.squareup.okhttp.internal.**

 #### -- Apache Commons --

 -dontwarn org.apache.commons.logging.**

     -ignorewarnings 
-keep class * {
public private protected *;
}

Solution 4:

I have changed nothing just comment

// shrinkResources true
// minifyEnabled true

you don't want to change any proguard file I have already searched for this issue after 2days wasted