错误:任务':app:transformClassesWithDexForDebug'执行失败 - 对于multidex应用程序

时间:2016-01-30 07:34:51

标签: android android-gradle android-multidex

运行/构建我的应用程序的APK时出现此错误。

Information:Gradle tasks [:app:assembleDebug]
:app:preBuild
:linkedin-sdk:preBuild
:app:preBuild UP-TO-DATE
:linkedin-sdk:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:linkedin-sdk:preReleaseBuild
:app:checkDebugManifest
:linkedin-sdk:preReleaseBuild UP-TO-DATE
:linkedin-sdk:compileReleaseNdk UP-TO-DATE
:app:preReleaseBuild
:linkedin-sdk:compileLint
:app:preReleaseBuild UP-TO-DATE
:app:preDebugAndroidTestBuild UP-TO-DATE
:linkedin-sdk:copyReleaseLint UP-TO-DATE
:app:generateDebugBuildConfig
:linkedin-sdk:checkReleaseManifest
:linkedin-sdk:preDebugAndroidTestBuild UP-TO-DATE
:linkedin-sdk:preDebugBuild UP-TO-DATE
:linkedin-sdk:preDebugUnitTestBuild UP-TO-DATE
:linkedin-sdk:preReleaseUnitTestBuild UP-TO-DATE
:linkedin-sdk:prepareComAndroidSupportSupportV42103Library
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:processDebugGoogleServices
:linkedin-sdk:prepareComAndroidSupportSupportV42103Library UP-TO-DATE
:linkedin-sdk:prepareReleaseDependencies
:linkedin-sdk:compileReleaseAidl
:app:compileDebugNdk UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:validateDebugSigning
:linkedin-sdk:compileReleaseAidl UP-TO-DATE
:linkedin-sdk:compileReleaseRenderscript UP-TO-DATE
:linkedin-sdk:generateReleaseBuildConfig UP-TO-DATE
:linkedin-sdk:generateReleaseAssets UP-TO-DATE
:linkedin-sdk:mergeReleaseAssets UP-TO-DATE
:linkedin-sdk:generateReleaseResValues UP-TO-DATE
:linkedin-sdk:generateReleaseResources UP-TO-DATE
:linkedin-sdk:mergeReleaseResources UP-TO-DATE
:linkedin-sdk:processReleaseManifest UP-TO-DATE
:linkedin-sdk:processReleaseResources UP-TO-DATE
:linkedin-sdk:generateReleaseSources UP-TO-DATE
:linkedin-sdk:compileReleaseJavaWithJavac UP-TO-DATE
:linkedin-sdk:extractReleaseAnnotations UP-TO-DATE
:linkedin-sdk:mergeReleaseProguardFiles UP-TO-DATE
:linkedin-sdk:packageReleaseRenderscript UP-TO-DATE
:linkedin-sdk:packageReleaseResources UP-TO-DATE
:linkedin-sdk:processReleaseJavaRes UP-TO-DATE
:linkedin-sdk:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
:linkedin-sdk:transformClassesAndResourcesWithSyncLibJarsForRelease UP-TO-DATE
:linkedin-sdk:mergeReleaseJniLibFolders UP-TO-DATE
:linkedin-sdk:transformNative_libsWithMergeJniLibsForRelease UP-TO-DATE
:linkedin-sdk:transformNative_libsWithSyncJniLibsForRelease UP-TO-DATE
:linkedin-sdk:bundleRelease UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:prepareComAndroidSupportCardviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2311Library UP-TO-DATE
:app:prepareComAndroidSupportMediarouterV72220Library UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE
:app:prepareComAppyvetMaterialrangebar13Library UP-TO-DATE
:app:prepareComFacebookAndroidFacebookAndroidSdk470Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppstate830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAuth830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBasement830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGames830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMeasurement830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesVision830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet830Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable830Library UP-TO-DATE
:app:prepareComPkmmteViewCircularimageview11Library UP-TO-DATE
:app:prepareComShehabicDroppyDroppy0252Library UP-TO-DATE
:app:prepareComSplitwiseTokenautocomplete202Library UP-TO-DATE
:app:prepareComStripeStripeAndroid104Library UP-TO-DATE
:app:prepareTlandroidappLinkedinSdkUnspecifiedLibrary UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:transformClassesWithJarMergingForDebug UP-TO-DATE
:app:collectDebugMultiDexComponents UP-TO-DATE
:app:transformClassesWithMultidexlistForDebug UP-TO-DATE
:app:transformClassesWithDexForDebug
Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
1 error; aborting
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1
Information:BUILD FAILED
Information:Total time: 2 mins 18.454 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

我几乎尝试了互联网上的所有解决方案,但没有用。这是我的build.gradle文件:

apply plugin: 'com.android.application'


android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'



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


    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    sourceSets { main { res.srcDirs = ['src/main/res', 'src/main/res/xml'] } }
}



dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.pkmmte.view:circularimageview:1.1'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.shehabic.droppy:Droppy:0.2.5.2@aar'
    compile 'com.android.support:design:23.1.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.splitwise:tokenautocomplete:2.0.2@aar'
    compile 'com.appyvet:materialrangebar:1.3'
    compile 'com.google.android.gms:play-services:8.3.0'
    compile 'com.google.android.gms:play-services-analytics:8.3.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.facebook.android:facebook-android-sdk:4.7.0'
    compile project(':linkedin-sdk')
    compile 'com.stripe:stripe-android:+'
}
apply plugin: 'com.google.gms.google-services'

这是项目级build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
        classpath 'com.google.gms:google-services:1.5.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
    }
}

linkedIn库还有一个gradle文件,它在这里:

allprojects {
    repositories {
        mavenCentral()
    }
}

buildscript {
   repositories {
     mavenCentral()
   }

}

apply plugin: 'android-library'

android {
    sourceSets {
        androidTest {
          setRoot('src/test')
        }
    }
    compileSdkVersion 17 
    buildToolsVersion '23.0.2'

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 16 
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
          abortOnError false
    }
}

configurations {
}


dependencies {
    compile 'com.android.support:support-annotations:20.0.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile files('libs/volley.jar')
    androidTestCompile('junit:junit:4.12')
}

注意:我的应用程序是Multidex应用程序,我已经扩展了Multidex类。

4 个答案:

答案 0 :(得分:6)

很抱歉打扰你们。感谢您的关注和上述所有答案。我通过添加我的gradle文件解决了这个问题。

dexOptions {
    javaMaxHeapSize "4g"
}

答案 1 :(得分:0)

因为您正在使用重复依赖

compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.android.gms:play-services-analytics:8.3.0'
compile 'com.android.support:multidex:1.0.1'

除去

compile 'com.google.android.gms:play-services-analytics:8.3.0'
compile 'com.android.support:multidex:1.0.1'

答案 2 :(得分:0)

build.gradle文件中存在重复的依赖关系

您已添加

compile 'com.android.support:multidex:1.0.1'

在构建文件中两次。删除其中一个,清理您的项目并尝试重建它。它应该工作正常。

当您添加了重复的依赖项时,通常会发生这种情况。您可以执行 gradle dependencies 命令查看是否存在重复项,并轻松删除它们。

答案 3 :(得分:0)

你有两个重复的依赖:

 compile 'com.android.support:multidex:1.0.1'
 compile 'com.google.android.gms:play-services:8.3.0'
 compile 'com.google.android.gms:play-services-analytics:8.3.0'

删除分析或服务。你也写了两次,你也可以使用multidex一个