无法在 Android Studio 3.0 Canary 1 下编译

Unable to compile under Android Studio 3.0 Canary 1

我尝试在 AS 3.0 Canary 1 下编译我的 Android 项目(它在 AS 2.3.2 稳定版上运行良好)但失败并出现以下错误:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:packageInstantRunResourcesUatGoogleDebug'.
> com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:packageInstantRunResourcesUatGoogleDebug'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:98)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:68)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:60)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:248)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:239)
    at org.gradle.internal.Transformers.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:114)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:239)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:226)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:120)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access0(DefaultTaskPlanExecutor.java:77)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.execute(DefaultTaskPlanExecutor.java:101)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.execute(DefaultTaskPlanExecutor.java:95)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:527)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:95)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.StoppableExecutorImpl.run(StoppableExecutorImpl.java:46)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.tooling.BuildException: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
    at com.android.build.gradle.internal.scope.SplitScope.lambda$parallelForEachOutput(SplitScope.java:243)
    at com.android.build.gradle.internal.scope.SplitScope.parallelForEachOutput(SplitScope.java:238)
    at com.android.build.gradle.internal.scope.SplitScope.parallelForEachOutput(SplitScope.java:198)
    at com.android.build.gradle.internal.scope.SplitScope.parallelForEachOutput(SplitScope.java:182)
    at com.android.build.gradle.tasks.PackageAndroidArtifact.doFullTaskAction(PackageAndroidArtifact.java:301)
    at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:80)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:161)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:132)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:115)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:109)
    at org.gradle.internal.Transformers.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:114)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:109)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:90)
    ... 26 more
Caused by: java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
    at com.android.apkzlib.zip.ZFile.createSources(ZFile.java:1586)
    at com.android.apkzlib.zip.ZFile.makeStoredEntry(ZFile.java:1546)
    at com.android.apkzlib.zip.ZFile.add(ZFile.java:1625)
    at com.android.apkzlib.zfile.ApkZFileCreator.writeFile(ApkZFileCreator.java:141)
    at com.android.builder.internal.packaging.IncrementalPackager.updateFiles(IncrementalPackager.java:170)
    at com.android.builder.internal.packaging.IncrementalPackager.updateAssets(IncrementalPackager.java:229)
    at com.android.build.gradle.tasks.PackageAndroidArtifact.doTask(PackageAndroidArtifact.java:525)
    at com.android.build.gradle.tasks.PackageAndroidArtifact.splitFullAction(PackageAndroidArtifact.java:359)
    at com.android.build.gradle.internal.scope.SplitScope.lambda$parallelForEachOutput(SplitScope.java:187)
    at com.android.build.gradle.internal.scope.SplitScope.lambda$parallelForEachOutput(SplitScope.java:204)
    at com.android.build.gradle.internal.scope.SplitScope.lambda$null(SplitScope.java:226)
    at com.android.ide.common.internal.WaitableExecutor.waitForAllTasks(WaitableExecutor.java:215)
    at com.android.build.gradle.internal.scope.SplitScope.parallelForEachOutput(SplitScope.java:237)
    ... 41 more
    Suppressed: java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
        at com.android.apkzlib.zip.ZFile.createSources(ZFile.java:1586)
        at com.android.apkzlib.zip.ZFile.makeStoredEntry(ZFile.java:1546)
        at com.android.apkzlib.zip.ZFile.add(ZFile.java:1625)
        at com.android.apkzlib.zip.ZFile.add(ZFile.java:1499)
        at com.android.apkzlib.sign.ManifestGenerationExtension.updateManifest(ManifestGenerationExtension.java:241)
        at com.android.apkzlib.sign.ManifestGenerationExtension.access[=11=]0(ManifestGenerationExtension.java:52)
        at com.android.apkzlib.sign.ManifestGenerationExtension.lambda$beforeUpdate[=11=](ManifestGenerationExtension.java:168)
        at com.android.apkzlib.zip.ZFile.notify(ZFile.java:2099)
        at com.android.apkzlib.zip.ZFile.update(ZFile.java:871)
        at com.android.apkzlib.zip.ZFile.close(ZFile.java:1161)
        at com.android.apkzlib.zfile.ApkZFileCreator.close(ApkZFileCreator.java:172)
        at com.google.common.io.Closer.close(Closer.java:213)
        at com.android.builder.internal.packaging.IncrementalPackager.close(IncrementalPackager.java:330)
        at com.android.build.gradle.tasks.PackageAndroidArtifact.doTask(PackageAndroidArtifact.java:535)
        at com.android.build.gradle.tasks.PackageAndroidArtifact.splitFullAction(PackageAndroidArtifact.java:359)
        at com.android.build.gradle.internal.scope.SplitScope.lambda$parallelForEachOutput(SplitScope.java:187)
        at com.android.build.gradle.internal.scope.SplitScope.lambda$parallelForEachOutput(SplitScope.java:204)
        at com.android.build.gradle.internal.scope.SplitScope.lambda$null(SplitScope.java:226)
        at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
        at java.util.concurrent.ForkJoinTask.externalAwaitDone(ForkJoinTask.java:326)
        at java.util.concurrent.ForkJoinTask.doJoin(ForkJoinTask.java:391)
        at java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:719)
        at com.android.ide.common.internal.WaitableExecutor.waitForAllTasks(WaitableExecutor.java:215)
        at com.android.build.gradle.internal.scope.SplitScope.parallelForEachOutput(SplitScope.java:237)
        at com.android.build.gradle.internal.scope.SplitScope.parallelForEachOutput(SplitScope.java:198)
        at com.android.build.gradle.internal.scope.SplitScope.parallelForEachOutput(SplitScope.java:182)
        at com.android.build.gradle.tasks.PackageAndroidArtifact.doFullTaskAction(PackageAndroidArtifact.java:301)
        at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:80)
        at sun.reflect.GeneratedMethodAccessor387.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:161)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:132)
        at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:115)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:109)
        at org.gradle.internal.Transformers.transform(Transformers.java:169)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:114)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:109)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:90)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:68)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:60)
        at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:248)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:239)
        at org.gradle.internal.Transformers.transform(Transformers.java:169)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:114)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:239)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:226)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:120)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access0(DefaultTaskPlanExecutor.java:77)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.execute(DefaultTaskPlanExecutor.java:101)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.execute(DefaultTaskPlanExecutor.java:95)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:527)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:95)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.StoppableExecutorImpl.run(StoppableExecutorImpl.java:46)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        at java.lang.Thread.run(Thread.java:745)


BUILD FAILED in 2s
18 actionable tasks: 6 executed, 12 avoided (67%)

我不确定这是否与我导入的 guava 19.0 库有关。下面列出了我使用的库:

dependencies {
    compile fileTree(include: ['*.jar'], excludes: ["pushservice-${baiduLibVersion}.jar", 'native-libs.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile("com.android.support:appcompat-v7:${supportLibVersion}") {
        exclude module: 'support-v4'
    }
    compile "com.android.support:support-fragment:${supportLibVersion}"
    compile "com.android.support:design:${supportLibVersion}"
    compile "com.android.support:percent:${supportLibVersion}"
    compile "com.android.support:gridlayout-v7:${supportLibVersion}"
    compile "com.google.android.gms:play-services-analytics:${playServiceLibVersion}"

    compile "com.google.firebase:firebase-messaging:${playServiceLibVersion}"
    // Cloud Messaging and Notifications
    compile "com.google.firebase:firebase-crash:${playServiceLibVersion}"
    compile "com.google.firebase:firebase-appindexing:${playServiceLibVersion}"
    compile "com.google.android.gms:play-services-auth:${playServiceLibVersion}"
    // google account login
    compile "com.google.android.gms:play-services-location:${playServiceLibVersion}"

    compile('com.github.AndroidDeveloperLB:AutoFitTextView:3') {
        exclude group: 'com.android.support', module: 'appcompat-v7'
    }
    compile('com.github.ksoichiro:android-observablescrollview:1.6.0') {
        exclude group: 'com.android.support', module: 'recyclerview-v7'
    }
    compile('com.bignerdranch.android:expandablerecyclerview:2.1.1') {
        exclude group: 'com.android.support', module: 'recyclerview-v7'
    }
    compile('com.facebook.android:facebook-android-sdk:4.13.2') {
        exclude group: 'com.android.support', module: 'support-v4'
    }
    compile 'com.android.support:multidex:1.0.1'
    compile 'in.co.ophio:secure-preferences:0.1.3'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.google.dagger:dagger:2.7'
    compile 'com.squareup.phrase:phrase:1.1.0'
    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'javax.annotation:javax.annotation-api:1.2'
    compile 'uk.co.chrisjenx:calligraphy:2.2.0'
    compile 'com.githang:com-phillipcalvin-iconbutton:2.0.2'
    compile 'com.github.seanzor:shared-preferences-helper:1.1.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@jar'
    compile 'com.github.aakira:expandable-layout:1.6.0@aar'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'org.parceler:parceler-api:1.1.5'
    compile 'io.reactivex:rxandroid:1.2.1'
    compile 'io.reactivex:rxjava:1.1.6'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'org.apmem.tools:layouts:1.10@aar'
    compile 'com.bigkoo:pickerview:2.1.1'
    compile 'com.newrelic.agent.android:android-agent:5.7.1'
    compile 'com.google.guava:guava:19.0'
    compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.1'
    compile 'com.vdurmont:semver4j:2.0.2'
    testCompile 'junit:junit:4.12'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.7'
    annotationProcessor 'org.parceler:parceler:1.1.5'
    checkstyle 'com.puppycrawl.tools:checkstyle:6.5'
}

我在我的 Win7 PC 上看到 "Execution failed for task" 错误,从 Android studio 2.4 开始,现在是 3.0 canary 运行ning。似乎对我有帮助的是 运行 任务管理器,然后终止 java.exe 进程。在那之后对我来说构建运行s 干净地完成了。

当我创建一个新项目并逐行添加这些行时,我遇到了完全相同的问题。

导致问题的行是

classpath 'com.google.firebase:firebase-plugins:1.1.0'

在项目 build.gradle 文件中。删除该行可以解决问题。

问题是新的 Android 插件版本 3.0.0-alpha1

只需将插件恢复到 2.3 或 2.4-alpha7 并使用 gradle 3.5,它将与 Firebase 插件一起工作

Firebase 团队建议使用此作为修复方法:

classpath ('com.google.firebase:firebase-plugins:1.1.0') {
    exclude group: 'com.google.guava', module: 'guava-jdk5'
}

编辑: 包括新的更新包将自动排除 guava-jdk5 包。

classpath 'com.google.firebase:firebase-plugins:1.1.1'

除了 firebase 如果您有任何其他构建脚本(可能是自定义构建脚本),即使用 Guava 库,您必须将其升级到 guava:21:0 或从中排除番石榴