【问题标题】:Error:Execution failed for task ':app:transformClassesWithDexForDebug'. > com.android.build.api.transform.TransformException:..non-zero exit value 3错误:任务“:app:transformClassesWithDexForDebug”执行失败。 > com.android.build.api.transform.TransformException:..非零退出值 3
【发布时间】:2016-03-24 17:47:10
【问题描述】:

Clean Project -> Rebuild Project 我的 android 项目出现以下错误

错误:任务 ':app:transformClassesWithDexForDebug' 执行失败。 > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: 进程'命令'/usr/lib/jvm/java-7- oracle/bin/java'' 以非零退出值 3 结束

分级:

    apply plugin: 'com.android.application'

    android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.myapplicationname.app"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    useLibrary 'org.apache.http.legacy'

}

    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile 'com.google.android.gms:play-services:8.3.0'
    compile files('libs/gcm.jar')
    compile 'com.android.support:multidex:1.0.1'
    compile 'org.apache.httpcomponents:httpcore:4.4.4'
    compile('org.apache.httpcomponents:httpmime:4.3.6') {
        exclude module: "httpclient"
    }
    //facebook sdk
    compile 'com.facebook.android:facebook-android-sdk:4.7.0'
    compile 'org.apache.httpcomponents:httpcore:4.4.3'

    compile 'com.paypal.sdk:paypal-android-sdk:2.12.4'
    //facebook sdk
    compile 'com.facebook.android:facebook-android-sdk:4.7.0'

}

我已经参考了 this , this ,但我找不到我的解决方案。我需要做些什么来解决它。

【问题讨论】:

    标签: android android-studio android-gradle-plugin build.gradle


    【解决方案1】:

    我刚刚更新了我的 gradle 文件,如下所示。这项工作就像魅力一样!!

    我在我的 gradle 中添加了以下代码:

    dexOptions {
            javaMaxHeapSize "4g" //specify the heap size for the dex process
            preDexLibraries = false //delete the already predexed libraries
        }
    

    我更新的Gradle

        apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.1"
    
        defaultConfig {
            applicationId "com.myapplicationname.app"
            minSdkVersion 15
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
            multiDexEnabled true
        }
      //====================Add below two line=============
        dexOptions {
            javaMaxHeapSize "4g" //specify the heap size for the dex process
            preDexLibraries = false //delete the already predexed libraries
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
        }
        useLibrary 'org.apache.http.legacy'
    
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:23.0.1'
        compile 'com.android.support:design:23.0.1'
        compile 'com.google.android.gms:play-services:8.3.0'
        compile files('libs/gcm.jar')
        compile 'com.android.support:multidex:1.0.1'
        compile 'org.apache.httpcomponents:httpcore:4.4.4'
        compile('org.apache.httpcomponents:httpmime:4.3.6') {
            exclude module: "httpclient"
        }
        //facebook sdk
        compile 'com.facebook.android:facebook-android-sdk:4.7.0'
        compile 'org.apache.httpcomponents:httpcore:4.4.3'
    
        compile 'com.paypal.sdk:paypal-android-sdk:2.12.4'
        //facebook sdk
        compile 'com.facebook.android:facebook-android-sdk:4.7.0'
    
    }
    

    【讨论】:

    • 拯救我的生命,但要注意解释这个问题到底是什么鬼,以及为什么代码可以解决它?谢谢
    【解决方案2】:

    可能的解决方案是指定您正在使用的播放服务

    compile 'com.google.android.gms:play-services:8.3.0'
    

    例如:

    compile 'com.google.android.gms:play-services-maps:8.3.0'
    

    这将减少方法总数。

    【讨论】:

      猜你喜欢
      • 2017-05-31
      • 1970-01-01
      • 2016-02-16
      • 1970-01-01
      • 2016-02-23
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      相关资源
      最近更新 更多