运行应用程序时Gradle错误transformDexArchiveWithDexMergerForDebug

时间:2017-10-06 12:48:12

标签: android android-gradle android-studio-3.0

我的应用程序构建正常,我可以创建signed apk但是当我尝试在我的设备上实际调试它时,我得到了这个gradle错误

Error:08:38:07.975 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
08:38:07.975 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > com.android.build.api.transform.TransformException: java.lang.IllegalStateException
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
08:38:07.976 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.lang.RuntimeException: com.android.build.api.transform.TransformException: java.lang.IllegalStateException
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:213)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 27 more
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: com.android.build.api.transform.TransformException: java.lang.IllegalStateException
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.transforms.DexMergerTransform.transform(DexMergerTransform.java:230)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:222)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:218)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 39 more
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.lang.IllegalStateException
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.google.common.base.Preconditions.checkState(Preconditions.java:441)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.pipeline.IntermediateFolderUtils.getContentLocation(IntermediateFolderUtils.java:101)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.pipeline.TransformOutputProviderImpl.getContentLocation(TransformOutputProviderImpl.java:51)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.transforms.DexMergerTransform.getDexOutputLocation(DexMergerTransform.java:588)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.transforms.DexMergerTransform.processNonExternalJarsTogether(DexMergerTransform.java:419)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.transforms.DexMergerTransform.handleNativeMultiDex(DexMergerTransform.java:307)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at com.android.build.gradle.internal.transforms.DexMergerTransform.transform(DexMergerTransform.java:213)
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 42 more
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] 
08:38:07.977 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 1m 11s

我使用的是Android Studio 3 Beta 7,这是我的build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.firebase.firebase-perf'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"

    dexOptions{
        javaMaxHeapSize = "4g"
    }

    defaultConfig {
        applicationId "com.xxx.xxx.xxx"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 40
        versionName "2.0.1"
        multiDexEnabled true
    }

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

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    sourceSets {
        main {
            java.srcDirs = ['src/main/java', 'src/androidTest/java/com....', 'src/test/java/com....', 'src/main/kotlin']
        }
    }
}

ext{
    supportLibraryVersion = "26.1.0"
    playServicesVersion = "11.4.2"
    archRoomVersion = "1.0.0-alpha3"
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    provided 'org.glassfish:javax.annotation:10.0-b28'
    compile "com.android.support:appcompat-v7:${supportLibraryVersion}"
    compile "com.android.support:recyclerview-v7:${supportLibraryVersion}"
    compile "com.android.support:support-annotations:${supportLibraryVersion}"
    compile "com.android.support:design:${supportLibraryVersion}"
    compile "com.android.support:cardview-v7:${supportLibraryVersion}"
    compile "com.google.android.gms:play-services-vision:${playServicesVersion}"
    compile "com.google.android.gms:play-services-location:${playServicesVersion}"
    compile "com.google.android.gms:play-services-base:${playServicesVersion}"
    compile "com.google.firebase:firebase-messaging:${playServicesVersion}"
    compile "com.google.firebase:firebase-core:${playServicesVersion}"
    compile "com.google.firebase:firebase-perf:${playServicesVersion}"
    compile "com.google.firebase:firebase-crash:${playServicesVersion}"
    compile ("com.google.firebase:firebase-config:${playServicesVersion}"){
        exclude group: 'com.google.firebase', module:'firebase-auth'
    }
    compile 'com.squareup.okhttp3:logging-interceptor:3.9.0'
    compile 'com.squareup.okhttp3:okhttp:3.9.0'
    compile 'com.gordonwong:material-sheet-fab:1.2.1'
    compile 'com.firebase:firebase-jobdispatcher:0.8.2'
    compile 'com.android.support:multidex:1.0.2'
    compile 'com.github.bumptech.glide:glide:3.8.0'
    compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile files('libs/ksoap2-android-assembly-3.6.0-jar-with-dependencies.jar')
    androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.2'){
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    androidTestCompile ('com.android.support.test:runner:0.5'){
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

//    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}

apply plugin: 'com.google.gms.google-services'
repositories {
    mavenCentral()
}

我做了很多清理/重建/无效缓存/重启但没有任何帮助,我不知道还有什么办法来解决这个问题

2 个答案:

答案 0 :(得分:1)

看起来它与multidex相关,我删除了它和任何与之相关的东西,现在一切正常

答案 1 :(得分:0)

尝试删除项目中的.gradle文件夹和所有构建文件夹。运行干净。