Skip to content

Compilation error on the androidTest configuration after updating to 1.3.6 #2023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dmarin opened this issue May 13, 2020 · 33 comments
Closed
Assignees
Labels

Comments

@dmarin
Copy link

dmarin commented May 13, 2020

The compilation error occurs after updating to 1.3.6, and it gets fixed if I downgrade to 1.3.5.

Kotlin Version 1.3.72

The coroutines dependencies I am using are:

implementation platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:${Versions.COROUTINES_VERSION}")
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services"

testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test"
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test"

Stacktrace:

* What went wrong:
Execution failed for task ':app:mergeStagingDebugAndroidTestJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > More than one file was found with OS independent path 'win32-x86/attach_hotspot_windows.dll'
* 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:mergeStagingDebugAndroidTestJavaResource'.
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:207)
	at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:263)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:205)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:186)
	at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:114)
	at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
	at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
	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.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
	at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:370)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:357)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:350)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: 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$WorkItemExecution.waitForCompletion(DefaultWorkerExecutor.java:334)
	at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsAndGatherFailures(DefaultAsyncWorkTracker.java:142)
	at org.gradle.internal.work.DefaultAsyncWorkTracker.access$000(DefaultAsyncWorkTracker.java:34)
	at org.gradle.internal.work.DefaultAsyncWorkTracker$1.run(DefaultAsyncWorkTracker.java:106)
	at org.gradle.internal.Factories$1.create(Factories.java:26)
	at org.gradle.internal.work.DefaultWorkerLeaseService.withoutLocks(DefaultWorkerLeaseService.java:260)
	at org.gradle.internal.work.DefaultWorkerLeaseService.withoutProjectLock(DefaultWorkerLeaseService.java:171)
	at org.gradle.internal.work.DefaultWorkerLeaseService.withoutProjectLock(DefaultWorkerLeaseService.java:165)
	at org.gradle.internal.work.StopShieldingWorkerLeaseService.withoutProjectLock(StopShieldingWorkerLeaseService.java:95)
	at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsAndGatherFailures(DefaultAsyncWorkTracker.java:102)
	at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForAll(DefaultAsyncWorkTracker.java:80)
	at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForCompletion(DefaultAsyncWorkTracker.java:68)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.run(ExecuteActionsTaskExecuter.java:577)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:554)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:537)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$300(ExecuteActionsTaskExecuter.java:108)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.executeWithPreviousOutputFiles(ExecuteActionsTaskExecuter.java:278)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:267)
	at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$0(ExecuteStep.java:32)
	at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:32)
	at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
	at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:67)
	at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:36)
	at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:49)
	at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:34)
	at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:43)
	at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
	at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
	at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:34)
	at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:44)
	at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:54)
	at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:38)
	at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
	at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:159)
	at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:72)
	at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:43)
	at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:44)
	at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:33)
	at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
	at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:92)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:85)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:55)
	at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:39)
	at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:76)
	at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
	at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
	at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
	at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:94)
	at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:49)
	at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:79)
	at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:53)
	at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:74)
	at org.gradle.internal.execution.steps.SkipEmptyWorkStep.lambda$execute$2(SkipEmptyWorkStep.java:78)
	at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:78)
	at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:34)
	at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:39)
	at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:40)
	at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:28)
	at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:194)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:186)
	at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:114)
	at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
	at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
	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.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
	at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:370)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:357)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:350)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: com.android.builder.merge.DuplicateRelativeFileException: More than one file was found with OS independent path 'win32-x86/attach_hotspot_windows.dll'
	at com.android.builder.merge.StreamMergeAlgorithms.lambda$acceptOnlyOne$2(StreamMergeAlgorithms.java:75)
	at com.android.builder.merge.StreamMergeAlgorithms.lambda$select$3(StreamMergeAlgorithms.java:100)
	at com.android.builder.merge.IncrementalFileMergerOutputs$1.create(IncrementalFileMergerOutputs.java:88)
	at com.android.builder.merge.DelegateIncrementalFileMergerOutput.create(DelegateIncrementalFileMergerOutput.java:64)
	at com.android.build.gradle.internal.tasks.MergeJavaResourcesDelegate$run$output$1.create(MergeJavaResourcesDelegate.kt:228)
	at com.android.builder.merge.IncrementalFileMerger.updateChangedFile(IncrementalFileMerger.java:242)
	at com.android.builder.merge.IncrementalFileMerger.mergeChangedInputs(IncrementalFileMerger.java:203)
	at com.android.builder.merge.IncrementalFileMerger.merge(IncrementalFileMerger.java:80)
	at com.android.build.gradle.internal.tasks.MergeJavaResourcesDelegate.run(MergeJavaResourcesDelegate.kt:257)
	at com.android.build.gradle.internal.tasks.MergeJavaResRunnable.run(MergeJavaResRunnable.kt:81)
	at com.android.build.gradle.internal.tasks.Workers$ActionFacade.run(Workers.kt:348)
	at org.gradle.workers.internal.AdapterWorkAction.execute(AdapterWorkAction.java:57)
	at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
	at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:66)
	at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:62)
	at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:98)
	at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:62)
	at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
	at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
	at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
	at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:59)
	at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$2(DefaultWorkerExecutor.java:198)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:215)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
	... 3 more```
@dmarin
Copy link
Author

dmarin commented May 13, 2020

I found 2 workarounds:

  1. Exclude the duplicated files:
    packagingOptions {
        exclude "**/attach_hotspot_windows.dll"
        exclude "META-INF/licenses/**"
        exclude "META-INF/AL2.0"
        exclude "META-INF/LGPL2.1"
    }
  1. Exclude the kotlinx-coroutines-debug dependency
resolutionStrategy {
  exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-debug"
}

@dmarin dmarin changed the title Compilation error on the androidTest project after updating to 1.3.6 Compilation error on the androidTest configuration after updating to 1.3.6 May 13, 2020
@caiodev
Copy link

caiodev commented May 20, 2020

Thanks @dmarin. Just by putting:

packagingOptions {
exclude 'META-INF/AL2.0'
exclude 'META-INF/LGPL2.1'
}

Already did the trick

@qwwdfsad qwwdfsad self-assigned this May 20, 2020
@qwwdfsad
Copy link
Collaborator

Could you please provide a reference to a reproducing Android project? Unfortunately, I cannot reproduce this build failure on simple projects

@proto-mvp
Copy link

proto-mvp commented May 20, 2020

getting similar error on androidTest

> More than one file was found with OS independent path 'META-INF/AL2.0'

packagingOptions {
exclude 'META-INF/AL2.0'
exclude 'META-INF/LGPL2.1'
}

and
exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-debug"

Above suggestions do help on the problem when compiling for AndroidTest.

In case of multi-module setup, the exclude of the dependency should be applied to all the modules.

Kotlin coroutines upgraded to 1.3.6
Kotlin Version 1.3.72.

@dmarin
Copy link
Author

dmarin commented May 20, 2020

Could you please provide a reference to a reproducing Android project? Unfortunately, I cannot reproduce this build failure on simple projects

I can reproduce part of the problem on a brand new project created from AS.

Steps:

  1. In AS -> File -> New -> New project. On my test I chose the empty activity template, but I guess it can be reproduced with any of them.
  2. in the app/build.gradle add the following snippet.
    implementation platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.7")
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services"
    testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test"
    androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test"
  1. Try to run the ExampleInstrumentedTest test and you will get the compilation error.
    More than one file was found with OS independent path 'META-INF/AL2.0'

Notes:
Changing the kotlin bom version to 1.3.5 "fixes" compilation. So this issue was introduced in 1.3.6
In my project setup the first error I was getting was different:
More than one file was found with OS independent path 'win32-x86/attach_hotspot_windows.dll'
So probably there are 2 different issues?

@qwwdfsad Is this enough? or should I publish the repo reproducing the issue somewhere?

@qwwdfsad
Copy link
Collaborator

That's enough, thanks!

@adamfit
Copy link

adamfit commented Jun 10, 2020

Seems to be related to a newer version of bytebuddy.

~/.gradle/caches$ unzip -l ./modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-debug/1.3.6/f4903dfe7f3d0d3a5143496576e2b346230e602c/kotlinx-coroutines-debug-1.3.6.jar | grep dll
   326686  03-28-2020 22:43   win32-x86-64/attach_hotspot_windows.dll
   279471  03-28-2020 22:43   win32-x86/attach_hotspot_windows.dll
~/.gradle/caches$ unzip -l ./modules-2/files-2.1/net.bytebuddy/byte-buddy-agent/1.10.5/d1c949ee74c3421ffd3d9159c867777ded928448/byte-buddy-agent-1.10.5.jar | grep dll
   279471  12-11-2019 20:22   win32-x86/attach_hotspot_windows.dll
   326686  12-11-2019 20:22   win32-x86-64/attach_hotspot_windows.dll

@alishen-diconium
Copy link

This issue still persists in 1.3.7

@dikhawk
Copy link

dikhawk commented Jul 18, 2020

This issue still persists in 1.3.8

@francescocervone
Copy link

Looks like just excluding kotlinx-coroutines-debug module solves the issue in 1.3.8.
No need to exclude anything with packagingOptions.

resolutionStrategy {
  exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-debug"
}

@caiodev
Copy link

caiodev commented Jul 25, 2020

@francescocervone That's what i got when i tried your solution:

No signature of method: build_2bz6cqdgyzucl8y9x7vl21swb.android() is applicable for argument types: (build_2bz6cqdgyzucl8y9x7vl21swb$_run_closure1) values: [build_2bz6cqdgyzucl8y9x7vl21swb$_run_closure1@18b6ad15]

The only thing that's working for me is:

packagingOptions {
exclude 'META-INF/AL2.0'
exclude 'META-INF/LGPL2.1'
}

@DDihanov
Copy link

DDihanov commented Jul 27, 2020

Same problem. I get this not only on the androidTest config. Seems to work with

packagingOptions {
        exclude "**/attach_hotspot_windows.dll"
        exclude "META-INF/licenses/**"
        exclude "META-INF/AL2.0"
        exclude "META-INF/LGPL2.1"
    }

Any idea how long we gotta keep this around? Until the next coroutines version or?

@brescia123
Copy link

@francescocervone Thanks Ciccio!

@joerogers
Copy link

I've tracked the problem to be a conflict between the kotlinx-coroutines-debug package and mockito and how they include the ByteBuddy library.

Mockito includes ByteBuddy as a dependency, however the coroutines-debug imbeds ByteBuddy directly. Seems the best solution is coroutines-debug switches to a dependency model or does something to ensure the embedded version will not conflict with other libraries.

While mockito is the dependency that I hit, it is possible other libraries that depend ByteBuddy could generate this conflict.

I'm working around the problem by excluding the debug library which is a drag along dependency that I am not using.

androidTestImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version") {
        // conflicts with mockito due to direct inclusion of byte buddy
        exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-debug"
    }

@DeuceTheCoder
Copy link

This issue still persists in 1.3.9

dkhalanskyjb added a commit that referenced this issue Oct 6, 2020
Added instructions to work around the long-standing problem
#2023.

Also, the answer to
#2274 is now
documented.
dkhalanskyjb added a commit that referenced this issue Oct 6, 2020
Added instructions to work around the long-standing problem
#2023.

Also, the answer to
#2274 is now
documented.
dkhalanskyjb added a commit that referenced this issue Oct 9, 2020
Added instructions to work around the long-standing problem
#2023.

Also, the answer to
#2274 is now
documented.
dkhalanskyjb added a commit that referenced this issue Oct 9, 2020
)

Added instructions to work around #2023 
Also, the answer to #2274 is now documented.

Co-authored-by: Vsevolod Tolstopyatov <[email protected]>
@dkhalanskyjb
Copy link
Collaborator

Using byte-buddy as a dependency instead of including it has other problems and wouldn't even solve this particular issue completely, so for now we've documented the workaround (the instructions have some details for those interested).

Also, a feature request for the Android build tools that, if implemented, would fix this: https://issuetracker.google.com/issues/170131605

@krzdabrowski
Copy link

This issue still persists in 1.4.0

recheej pushed a commit to recheej/kotlinx.coroutines that referenced this issue Dec 28, 2020
…tlin#2288)

Added instructions to work around Kotlin#2023 
Also, the answer to Kotlin#2274 is now documented.

Co-authored-by: Vsevolod Tolstopyatov <[email protected]>
recheej pushed a commit to recheej/kotlinx.coroutines that referenced this issue Dec 28, 2020
…tlin#2288)

Added instructions to work around Kotlin#2023 
Also, the answer to Kotlin#2274 is now documented.

Co-authored-by: Vsevolod Tolstopyatov <[email protected]>
@andreandyp
Copy link

I've tracked the problem to be a conflict between the kotlinx-coroutines-debug package and mockito and how they include the ByteBuddy library.

Mockito includes ByteBuddy as a dependency, however the coroutines-debug imbeds ByteBuddy directly. Seems the best solution is coroutines-debug switches to a dependency model or does something to ensure the embedded version will not conflict with other libraries.

While mockito is the dependency that I hit, it is possible other libraries that depend ByteBuddy could generate this conflict.

I'm working around the problem by excluding the debug library which is a drag along dependency that I am not using.

androidTestImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version") {
        // conflicts with mockito due to direct inclusion of byte buddy
        exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-debug"
    }

I updated all the test dependencies and androidTest dependencies and then added this snippet to my build.gradle (app). The packagingOptions never worked for me. Kotlin version: 1.4.21

@ZakTaccardi
Copy link

On Kotlin 1.4.30 and started observing this issue after upgrading to byte buddy 1.10.20.

Task that had this issue:

:lib:mergeDebugAndroidTestJavaResource

Fix was:

pickFirst("win32-x86/attach_hotspot_windows.dll")
pickFirst("win32-x86-64/attach_hotspot_windows.dll")
pickFirst("META-INF/licenses/ASM")

@neworld
Copy link

neworld commented Feb 11, 2021

I prefer to skip all DLLs. Android does not support it anyway:

exclude("win32-x86/attach_hotspot_windows.dll")
exclude("win32-x86-64/attach_hotspot_windows.dll")

@yusufceylan
Copy link

This issue still persists in 1.4.21

@qwwdfsad
Copy link
Collaborator

It's indeed is here, but unfortunately, there is nothing we can do about it.

We've added a section about it to readme a few releases ago.

galcyurio added a commit to galcyurio/todo-playground that referenced this issue Feb 22, 2021
@ejep520
Copy link

ejep520 commented Mar 31, 2021

I'm working on a Udacity/Kotlin/Android testing course UD940, lesson 11, and I am running into this error. The original is at Udacity's Github and I recommend you look at my code at this commit. I'm continuing to work on the course because of, and not despite this error; I think its a better example of what I may encounter in the wild than a nice, neat, well, planned lesson.

@beebeewijaya-tech
Copy link

exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-debug"

Solved by following this

@rosebm
Copy link

rosebm commented Apr 28, 2021

The issue persists on v1.4.3, but can mitigate it meanwhile with the exclusion #2023 (comment)

@andersu
Copy link

andersu commented Jun 10, 2021

Issue seems to be gone (for me) with Kotlin version 1.5.10

Sorry, I spoke too soon. Problem is still there.

@qwwdfsad
Copy link
Collaborator

I'm closing this issue, this is an Android limitation and, unfortunately, we cannot do much about it.
We've reported it to Google and also provided a workaround below (and in our documentation).

Please refrain from commenting that the issue is gone or still persists as it will only hide the workaround in the middle of the thread from people who first encountered it.

Solution copied from our documentation:

===

Building an Android project that depends on kotlinx-coroutines-debug (usually introduced by being a transitive
dependency of kotlinx-coroutines-test) may fail with DuplicateRelativeFileException for META-INF/AL2.0,
META-INF/LGPL2.1, or win32-x86/attach_hotspot_windows.dll when trying to merge the Android resource.

The problem is that Android merges the resources of all its dependencies into a single directory and complains about
conflicts, but:

  • kotlinx-coroutines-debug transitively depends on JNA and JNA-platform, both of which include license files in their
    META-INF directories. Trying to merge these files leads to conflicts, which means that any Android project that
    depends on JNA and JNA-platform will experience build failures.
  • Additionally, kotlinx-coroutines-debug embeds byte-buddy-agent and byte-buddy, along with their resource files.
    Then, if the project separately depends on byte-buddy, merging the resources of kotlinx-coroutines-debug with ones
    from byte-buddy and byte-buddy-agent will lead to conflicts as the resource files are duplicated.

One possible workaround for these issues is to add the following to the android block in your gradle file for the
application subproject:

     packagingOptions {
         // for JNA and JNA-platform
         exclude "META-INF/AL2.0"
         exclude "META-INF/LGPL2.1"
         // for byte-buddy
         exclude "META-INF/licenses/ASM"
         pickFirst "win32-x86-64/attach_hotspot_windows.dll"
         pickFirst "win32-x86/attach_hotspot_windows.dll"
     }

This will cause the resource merge algorithm to exclude the problematic license files altogether and only leave a single
copy of the files needed for byte-buddy-agent to work.

===

@EGOR-IND
Copy link

EGOR-IND commented Aug 8, 2021

I found 2 workarounds:

  1. Exclude the duplicated files:
    packagingOptions {
        exclude "**/attach_hotspot_windows.dll"
        exclude "META-INF/licenses/**"
        exclude "META-INF/AL2.0"
        exclude "META-INF/LGPL2.1"
    }
  1. Exclude the kotlinx-coroutines-debug dependency
resolutionStrategy {
  exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-debug"
}

Thanks @dmarin you are a life saver, I tried so many stack overflow solutions but they didn't worked but yours worked like a charm :)

@nafiskabbo

This comment has been minimized.

centic9 added a commit to centic9/EventFahrplan that referenced this issue Feb 13, 2022
…win32-x86/attach_hotspot_windows.dll'."

See Kotlin/kotlinx.coroutines#2023 for details and the documented workaround
centic9 added a commit to centic9/EventFahrplan that referenced this issue Feb 14, 2022
…win32-x86/attach_hotspot_windows.dll'."

See Kotlin/kotlinx.coroutines#2023 for details and the documented workaround
centic9 added a commit to centic9/EventFahrplan that referenced this issue Feb 14, 2022
…win32-x86/attach_hotspot_windows.dll'."

See Kotlin/kotlinx.coroutines#2023 for details and the documented workaround
@karuneshpalekar
Copy link

Solved for version of Kotlin = 1.6.10 in build.gradle.kts
androidTestImplementation(Libs.COROUTINES_TEST){
exclude("org.jetbrains.kotlinx","kotlinx-coroutines-debug")
}

cg072 added a commit to cg072/advanced-android-testing that referenced this issue Sep 14, 2023
1. mockito 라이브러리 추가
2. kotlinx-coroutines-debug에 의존되어 발생하는 파일 중첩 문제 수정
Kotlin/kotlinx.coroutines#2023
@lisonge
Copy link

lisonge commented Jul 16, 2024

 packagingOptions {
        exclude "**/attach_hotspot_windows.dll"
        exclude "META-INF/licenses/**"
        exclude "META-INF/AL2.0"
        exclude "META-INF/LGPL2.1"
}

Why do these files cause compilation failures? They are not code files, so why do they affect the compilation results?

@dkhalanskyjb
Copy link
Collaborator

@lisonge, they shouldn't affect the compilation results. They affect the linking results: putting everything into an archive fails, because the Android Gradle plugin can't decide which of the several files to include. As a result, we just exclude all of them, as none of them is useful in an Android project.

@manadragon
Copy link

manadragon commented Oct 18, 2024

android{
/**
packagingOptions is deprecated.
packagingOptions -> packaging
**/
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
excludes += "META-INF/LICENSE.md" // <-
excludes += "META-INF/LICENSE-notice.md" //<-
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests