Execution failed for task app:transformClassesAndResourcesWithProguardForDebug

泄露秘密 提交于 2019-12-21 07:16:07

问题


when i try to run my app i get these errors:

Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForDebug'.

java.io.IOException: Please correct the above warnings first.

This is my Gradle file
apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "24.0.2"

defaultConfig {
    applicationId "xxxxxxxxxxxxx"
    minSdkVersion 14
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug {
        minifyEnabled true
        shrinkResources true
    }
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.google.android.gms:play-services:9.8.00'
compile 'com.google.android.gms:play-services-auth:9.8.00'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.google.android.gms:play-services-ads:9.8.00'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.google.android.gms:play-services-gcm:9.8.00'
}
apply plugin: 'com.google.gms.google-services'

can any one say why am i getting this error?

it shows some jar files are duplicate ,but i dont know which dependency to remove.


回答1:


add the below to your ProGuard rules

-ignorewarnings



回答2:


Remove

debug {
        minifyEnabled true
    }

This worked for me




回答3:


Add following to the debug section:

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

If you are setting minifyEnabled to true, you need to have proguardFiles defined. If you don't need minifyEnabled, just set it to false. Then you don't need to add proguardFiles.




回答4:


Try this:

    debug {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'proguard.cfg'
    }



回答5:


I faced the same issue. So I checked the the third parties and update the third parties Gradle versions in my app level Gradle. It worked for me. Actual one the third party version was deprecated. Which was causing the issue. Hope it will help someone.




回答6:


adding useProguard true worked for me




回答7:


  1. Remove minifyEnabled true from debug if you are getting error while compiling the app. As this time its running debug part.

    buildTypes {
      debug {
        minifyEnabled true// (<--Remove)
        proguardFiles getDefaultProguardFile('proguard-android.txt'),
                'proguard-rules.pro'
      }
    }
    
  2. Remove minifyEnabled true from release if you are getting error while creating final releasing api.

    buildTypes {
      release {
        minifyEnabled true// (<--Remove)
        proguardFiles getDefaultProguardFile('proguard android.txt'), 'proguard-rules.pro'
      }
    }
    


来源:https://stackoverflow.com/questions/40258804/execution-failed-for-task-apptransformclassesandresourceswithproguardfordebug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!