Execution failed for task ':app:transformClassesWithAndroidGradleClassShrinkerForDebug' in Android Studio 3.1

假如想象 提交于 2019-12-06 14:31:22

It seems like a bug of Android Studio 3.1.1. It's Android Profiler injects some additional code that is not well-handled by ProGuard. Building APKs or executing gradle commands manually is not affected.

Option 1: (prefered) Disable advanced profiling.

Option 2: Disable shrinking for Debug builds

Option 3: Include okhttp library while deploying app from Android Studio. [probably only for debug flavor] (may be useful if measuring something, ProGuard will remove any unused methods, will be no big overhead)


If solutions/quickfixes above don't work, please make sure you are not using okhttp. Maybe you are - and it's not properly configured. You may use gradle app:dependencies to check if okhttp is referenced in your project or any linked libraries.

if you are using 3.1.1

  classpath 'com.android.tools.build:gradle:3.1.1'

then your app/build.gradle should be like given below

apply plugin: 'com.android.application' 
android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.z.a.zcamera"
    minSdkVersion 14
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(path: ':libzcamera')
implementation 'com.android.support:support-v4:27.1.0'
}

if buildToolsVersion require then use this

buildToolsVersion '27.0.3'

also change gradle in project(path: ':libzcamera')

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