我得到这个错误,而我正在构建APK。

Cause 1: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    at org.gradle.workers.internal.DefaultWorkerExecutor$WorkerExecution.waitForCompletion(DefaultWorkerExecutor.java:285)
    at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsAndGatherFailures(DefaultAsyncWorkTracker.java:115)
    at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForCompletion(DefaultAsyncWorkTracker.java:87)
    at org.gradle.workers.internal.DefaultWorkerExecutor.await(DefaultWorkerExecutor.java:150)
    at com.android.build.gradle.internal.tasks.Workers$WorkerExecutorAdapter.await(Workers.kt:282)
    at com.android.ide.common.resources.MergeWriter.end(MergeWriter.java:48)
    at com.android.ide.common.resources.MergedResourceWriter.end(MergedResourceWriter.java:242)
    at com.android.ide.common.resources.DataMerger.mergeData(DataMerger.java:292)
    at com.android.ide.common.resources.ResourceMerger.mergeData(ResourceMerger.java:384)
    at com.android.build.gradle.tasks.MergeResources.lambda$doFullTaskAction$1(MergeResources.java:261)
    at com.android.build.gradle.internal.tasks.Blocks.recordSpan(Blocks.java:58)

试图使缓存无效并重新启动android工作室。重建项目,但没有一个为我工作。


当前回答

在我的例子中,我启用了multidex

[project_folder] / app /构建开放。Gradle并添加以下行。

defaultConfig {
    ...

    multiDexEnabled true
}

and

dependencies {
    ...

    implementation 'com.android.support:multidex:2.0.1'
}

其他回答

当我直接从GitHub下载代码文件时,我遇到了这个问题,但它显示了这个错误,但我的同事告诉我使用“Git bash here”并使用命令来Gitclone它。这样做之后,它就可以正常工作了。

我通过添加以下行来解决这个问题

在android>应用>build中添加multiDexEnabled truegradle在defaultConfig里面 在android>应用>构建中添加实现'com.android.support:multidex:1.0.3'。Gradle内部依赖

How To Solve A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade Error? To Solve A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade Error Just open your app/build.gradle file and change this line. androidx.core:core-ktx:+ replace with androidx.core:core-ktx:1.6.0 Here is an Example. If you are using androidx.core:core-ktx:+ then this will find the latest version of androidx.core:core-ktx:+ and the latest one is 1.7.0 and the latest version needs the Android 31 compile SDK. So that You are facing this issue. Here is Two Possible Solution use a specific version, use androidx.core:core-ktx:${version} instead of androidx.core:core-ktx:+ upgrade the compile SDK to Android 31 full article is Here

比如我对Kotlin的看法 build.gradle:应用程序 添加一行依赖项: multiDexEnabled真实 并添加 Def multidex_version = "2.0.1" 实现“androidx.multidex: multidex: multidex_version美元”

在Android Studio试试这个

File > Invalidate Caches/Restart...