app:transformClassesWithDexForDebug'.> com.android.ide.common.process.ProcessException:以非零退出值 1



我现在正在搜索三天,但我没有找到这些异常的答案:

错误:Gradle:任务":app:transformClassesWithDexForDebug"的执行失败。

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: process 'command 'C:\Program Files\Java\jdk1.8.0_60\bin\java.exe'' 以非零退出值 1 完成

这是我的build.gradle文件:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 23
    buildToolsVersion '22.0.1'
    useLibrary  'org.apache.http.legacy'
    defaultConfig {
        applicationId "de.myApp"
        minSdkVersion 21
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

    }
    dexOptions {
        javaMaxHeapSize "4g" //specify the heap size for the dex process
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
        }
    }

}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.google.android.gms:play-services-appindexing:8.4.0'
    compile 'com.google.android.gms:play-services-auth:8.4.0'
    compile 'com.android.support:multidex:1.0.1'
    compile files('libs/achartengine-1.2.0.jar')
}

当我同步、清理和构建 gradle 项目时,一切都很好,但是当我想运行该应用程序时,我得到了这个异常......有没有人解决这个问题?

避免使用以下方法:

  • Android 的内部 Apache 库
  • 多晶硅
  • 罐子

试试这个新配置:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'
    defaultConfig {
        applicationId "de.myApp"
        minSdkVersion 21
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.google.android.gms:play-services-appindexing:8.4.0'
    compile 'com.google.android.gms:play-services-auth:8.4.0'
    compile files('libs/achartengine-1.2.0.jar') // I would use MP Android Chart
}
在您的

依赖项中看到compile 'com.android.support:multidex:1.0.1'并且minifyEnabled false很奇怪。

请检查你正在使用的代码和库是否超过了65K方法的数量,所以你需要使用multidexing,在这里查看更多。您还可以按照 Android 文档的建议正确实现多晶。

如果您使用的是一些旧的 gradle 构建工具版本,这里还有 'org.apache.http.legacy' 的已知问题,请参阅如何将 Apache HTTP API(遗留版(作为编译时依赖项添加到 build.grade for Android M?

最新更新