我得到这个错误,而我正在构建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工作室。重建项目,但没有一个为我工作。


当前回答

找到了解决方案。

将此代码添加到build.gradle中,

dependencies {
    def multidex_version = "2.0.1"
    implementation 'androidx.multidex:multidex:$multidex_version'
}

then enable the multidex to true

 defaultConfig {
        ...
        minSdkVersion 15 
        targetSdkVersion 28
        multiDexEnabled true
    }


其他回答

清理项目->使缓存无效/重新启动。我的问题就这样解决了。

在我的情况下,我使用react本机,它发生在gradle更新到新版本时。我就知道这和葛拉德卢有关。我检查了几天前我在github上推送的回购。我改变了gradle类在android/build中的路径。Gradle依赖项和添加项

classpath("com.android.tools.build:gradle:3.5.3")
classpath 'com.google.gms:google-services:4.3.3'

这解决了我的问题。

我更新了这个,并在gradle包装器属性中为我工作

distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip

这里我发现只需添加这一行gradle.properties

org . gradle jvmargs = -Xmx4g。

在Android Studio试试这个

File > Invalidate Caches/Restart...