任务“:app:mergeExtDexDebug”执行失败

Posted

技术标签:

【中文标题】任务“:app:mergeExtDexDebug”执行失败【英文标题】:Execution failed for task ':app:mergeExtDexDebug' 【发布时间】:2021-11-16 11:03:20 【问题描述】:

我在尝试为我的 android 应用程序构建调试 apk 时不断收到此错误。该应用在本机设备或模拟器上构建和运行。

Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform fastutil-8.3.0.jar (it.unimi.dsi:fastutil:8.3.0) to match attributes artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-is-debuggable=true, dexing-min-sdk=23, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime.
      > Execution failed for DexingWithClasspathTransform: /Users/kingsleyokoye/.gradle/caches/transforms-3/c6c5e6c867a7a9428e59b7cabb0a5c1a/transformed/jetified-fastutil-8.3.0.jar.
         > Error while dexing.

如果我使用 stacktrace 运行,我会收到更详细的错误消息。

> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform fastutil-8.3.0.jar (it.unimi.dsi:fastutil:8.3.0) to match attributes artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-is-debuggable=true, dexing-min-sdk=23, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime.
      > Execution failed for DexingWithClasspathTransform: /Users/kingsleyokoye/.gradle/caches/transforms-3/c6c5e6c867a7a9428e59b7cabb0a5c1a/transformed/jetified-fastutil-8.3.0.jar.
         > Error while dexing.

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

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:mergeExtDexDebug'.
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:38)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
    at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:74)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:408)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:395)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:388)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:374)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
org.gradle.api.internal.file.DefaultFileCollectionFactory$ResolvingFileCollection.visitChildren(DefaultFileCollectionFactory.java:333)
    at org.gradle.api.internal.file.CompositeFileCollection.visitContents(CompositeFileCollection.java:119)
    at org.gradle.api.internal.file.AbstractFileCollection.visitStructure(AbstractFileCollection.java:330)
    at org.gradle.api.internal.file.CompositeFileCollection.lambda$visitContents$0(CompositeFileCollection.java:119)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: org.gradle.api.internal.artifacts.transform.TransformException: Failed to transform fastutil-8.3.0.jar (it.unimi.dsi:fastutil:8.3.0) to match attributes artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-is-debuggable=true, dexing-min-sdk=23, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime.
    at org.gradle.api.internal.artifacts.transform.TransformingAsyncArtifactListener$TransformedArtifact.lambda$visit$2(TransformingAsyncArtifactListener.java:221)
    at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:268)
    at org.gradle.api.internal.artifacts.transform.TransformingAsyncArtifactListener$TransformedArtifact.visit(TransformingAsyncArtifactListener.java:213)
    at org.gradle.api.internal.artifacts.ivyservice.resolveengine.artifact.ParallelResolveArtifactSet$VisitingSet$StartVisitAction.visitResults(ParallelResolveArtifactSet.java:99)
org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:56)
    at 
org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable.runOperation(DefaultBuildOperationQueue.java:241)
    at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable.doRunBatch(DefaultBuildOperationQueue.java:222)
    at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable.lambda$runBatch$0(DefaultBuildOperationQueue.java:212)
    at org.gradle.internal.resources.AbstractResourceLockRegistry.whileDisallowingLockChanges(AbstractResourceLockRegistry.java:70)
    at org.gradle.internal.work.DefaultWorkerLeaseService.whileDisallowingProjectLockChanges(DefaultWorkerLeaseService.java:185)
org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:50)
    at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:47)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)

org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
org.gradle.cache.ManualEvictionInMemoryCache.get(ManualEvictionInMemoryCache.java:30)
    at org.gradle.cache.internal.DefaultCrossBuildInMemoryCacheFactory$CrossBuildCacheRetainingDataFromPreviousBuild.get(DefaultCrossBuildInMemoryCacheFactory.java:259)
    at org.gradle.cache.Cache.get(Cache.java:31)
    at org.gradle.internal.execution.steps.IdentityCacheStep.lambda$executeDeferred$1(IdentityCacheStep.java:47)
    ... 25 more
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: /Users/kingsleyokoye/.gradle/caches/transforms-3/c6c5e6c867a7a9428e59b7cabb0a5c1a/transformed/jetified-fastutil-8.3.0.jar:it/unimi/dsi/fastutil/objects/Reference2DoubleMap.class
    at Version.fakeStackEntry(Version_3.0.69.java:0)
    at com.android.tools.r8.utils.w.a(SourceFile:68)
    at com.android.tools.r8.utils.w.a(SourceFile:28)
    at com.android.tools.r8.utils.w.a(SourceFile:27)
    at com.android.tools.r8.utils.w.b(SourceFile:3)
    at com.android.tools.r8.D8.run(D8.java:11)
    at com.android.builder.dexing.D8DexArchiveBuilder.convert(D8DexArchiveBuilder.java:115)
    ... 115 more
Caused by: com.android.tools.r8.internal.q8: One or more instruction is preventing default interface method from being desugared: java.lang.Double it.unimi.dsi.fastutil.objects.Reference2DoubleMap.getOrDefault(java.lang.Object, java.lang.Double)
    at com.android.tools.r8.internal.Ei.a(SourceFile:111)
    at com.android.tools.r8.internal.Bi.a(SourceFile:586)
    at com.android.tools.r8.utils.V.a(SourceFile:36)
    at com.android.tools.r8.utils.V.a(SourceFile:41)
    at com.android.tools.r8.utils.V.a(SourceFile:35)
    at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)
    at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:69)
    at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutorService.execute(MoreExecutors.java:321)
    at com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:66)
    at com.google.common.util.concurrent.AbstractListeningExecutorService.submit(AbstractListeningExecutorService.java:36)
    at com.android.tools.r8.utils.V.a(SourceFile:34)
    at com.android.tools.r8.internal.sj.a(SourceFile:2)
    at com.android.tools.r8.internal.sj.forEach(SourceFile:2)
    at com.android.tools.r8.utils.V.a(SourceFile:6)
    at com.android.tools.r8.utils.V.a(SourceFile:40)
    at com.android.tools.r8.utils.V.a(SourceFile:38)
    at com.android.tools.r8.utils.V.a(SourceFile:37)
    at com.android.tools.r8.internal.Bi.a(SourceFile:574)
    at com.android.tools.r8.internal.Bi.a(SourceFile:560)
    at com.android.tools.r8.ir.conversion.k.a(SourceFile:12)
    at com.android.tools.r8.ir.conversion.k.a(SourceFile:64)
    at com.android.tools.r8.D8.d(D8.java:39)
    at com.android.tools.r8.D8.b(D8.java:1)
    at com.android.tools.r8.utils.w.a(SourceFile:24)
    ... 118 more
    Suppressed: java.lang.RuntimeException: java.util.concurrent.ExecutionException: com.android.tools.r8.internal.q8: One or more instruction is preventing default interface method from being desugared: java.lang.Double it.unimi.dsi.fastutil.objects.Reference2DoubleMap.getOrDefault(java.lang.Object, java.lang.Double)
        at com.android.tools.r8.D8.d(D8.java:209)
        at com.android.tools.r8.D8.b(D8.java:1)
        at com.android.tools.r8.utils.w.a(SourceFile:24)
        at com.android.tools.r8.utils.w.b(SourceFile:3)
        at com.android.tools.r8.D8.run(D8.java:11)
        at com.android.builder.dexing.D8DexArchiveBuilder.convert(D8DexArchiveBuilder.java:115)
        at com.android.build.gradle.internal.dependency.BaseDexingTransform.process(DexingTransform.kt:288)

org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
        at 
org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:105)
        at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:50)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.lambda$execute$2(SkipEmptyWorkStep.java:86)
        at java.base/java.util.Optional.orElseGet(Optional.java:369)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:86)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:32)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:38)
        at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:43)
        at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:31)
        at org.gradle.internal.execution.steps.AssignWorkspaceStep.lambda$execute$0(AssignWorkspaceStep.java:40)
        at org.gradle.internal.execution.workspace.impl.DefaultImmutableWorkspaceProvider.lambda$withWorkspace$3(DefaultImmutableWorkspaceProvider.java:120)
        at org.gradle.cache.internal.LockOnDemandCrossProcessCacheAccess.withFileLock(LockOnDemandCrossProcessCacheAccess.java:90)
        at org.gradle.cache.internal.DefaultCacheAccess.withFileLock(DefaultCacheAccess.java:191)
        at org.gradle.cache.internal.DefaultPersistentDirectoryStore.withFileLock(DefaultPersistentDirectoryStore.java:188)
        at org.gradle.cache.internal.DefaultCacheFactory$ReferenceTrackingCache.withFileLock(DefaultCacheFactory.java:209)
        at org.gradle.internal.execution.workspace.impl.DefaultImmutableWorkspaceProvider.withWorkspace(DefaultImmutableWorkspaceProvider.java:117)
        at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:40)

org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
        at java.base/java.lang.Thread.run(Thread.java:834)
    Caused by: java.util.concurrent.ExecutionException: com.android.tools.r8.internal.q8: One or more instruction is preventing default interface method from being desugared: java.lang.Double it.unimi.dsi.fastutil.objects.Reference2DoubleMap.getOrDefault(java.lang.Object, java.lang.Double)
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:566)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:527)
        at com.google.common.util.concurrent.FluentFuture$TrustedFuture.get(FluentFuture.java:88)
        at com.android.tools.r8.utils.V.a(SourceFile:11)
        at com.android.tools.r8.utils.V.a(SourceFile:40)
        at com.android.tools.r8.utils.V.a(SourceFile:38)
        at com.android.tools.r8.utils.V.a(SourceFile:37)
        at com.android.tools.r8.internal.Bi.a(SourceFile:574)
        at com.android.tools.r8.internal.Bi.a(SourceFile:560)
        at com.android.tools.r8.ir.conversion.k.a(SourceFile:12)
        at com.android.tools.r8.ir.conversion.k.a(SourceFile:64)
        at com.android.tools.r8.D8.d(D8.java:39)
        ... 126 more
    Caused by: [CIRCULAR REFERENCE: com.android.tools.r8.internal.q8: One or more instruction is preventing default interface method from being desugared: java.lang.Double it.unimi.dsi.fastutil.objects.Reference2DoubleMap.getOrDefault(java.lang.Object, java.lang.Double)]

我试过了

启用添加 Multidex 添加 dexOptions javaMaxHeapSize "4g" 在我的 gradle 属性文件中 添加实现 'com.android.support:multidex:1.0.3' 确保我的依赖项具有指定的版本号

但似乎没有一个有效。

【问题讨论】:

尝试清理项目并重建它。它可能工作 @Muhammed Arshad K,我试过多次,无效并重新启动,没有解决问题 【参考方案1】:

这可能是由 2 个问题引起的-

    在您的 gradle.properties 文件中,您是否启用了:
    android.useAndroidX=true
    android.enableJetifier=true
    jar 文件可能已损坏。只删除 fastutil-8.3.0.jar 文件,让 gradle 重新安装。

【讨论】:

请问如何找到 fastutil-8.20.jar 文件 一般在 %UserProfile%\.gradle\caches 文件夹中。使用搜索栏搜索并删除它。【参考方案2】:

根据this GitHub ticket确实有问题。尝试将库回滚到旧版本(7.2.1 对我有用)

【讨论】:

以上是关于任务“:app:mergeExtDexDebug”执行失败的主要内容,如果未能解决你的问题,请参考以下文章

如何在合并dex档案时解决错误?

正常任务(宏任务)和微任务

背水一战 Windows 10 (119) - 后台任务: 后台下载任务(任务分组,组完成后触发后台任务)

任务计划程序打开软件的原理

CELERY 定时任务

“异步任务然后等待任务”与“任务然后返回任务”[重复]