Kotlinx.coroutines: duplicate entry: META-INF/atomicfu.kotlin_module

Created on 31 Mar 2019  ·  40Comments  ·  Source: Kotlin/kotlinx.coroutines

I've tried this and it doesn't work. I'm a bit stuck. 😢

bug

Most helpful comment

packagingOptions {
        pickFirst 'META-INF/kotlinx-io.kotlin_module'
        pickFirst 'META-INF/atomicfu.kotlin_module'
        pickFirst 'META-INF/kotlinx-coroutines-io.kotlin_module'
    }

that worked with me.

All 40 comments

@SUPERCILEX , i have tried with

packagingOptions {
        pickfirst 'META-INF/atomicfu.kotlin_module'
}
packagingOptions {
        pickfirst 'META-INF/*'
}
packagingOptions {
        pickfirst '**'
}

and it is not working too !

packagingOptions {
        pickFirst 'META-INF/kotlinx-io.kotlin_module'
        pickFirst 'META-INF/atomicfu.kotlin_module'
        pickFirst 'META-INF/kotlinx-coroutines-io.kotlin_module'
    }

that worked with me.

@kherlopian2 , for me still not working. I mean it's OK in Debug build, but not in release

@kherlopian2 Nope, not working. 😢 @eakteam Are you using dynamic feature feature modules or instant apps?

@SUPERCILEX , Yes i am using Dynamic Feature Modules and this packaging options rules i have added in every build.gradle

Neat, so that's gotta be the bug somehow! I want to hear @qwwdfsad's thoughts, but then I'll file an issue if it's really Google's fault.

@SUPERCILEX , sure that this is a minor bug and for sure it will be solved, but @qwwdfsad i think its not his fault and maybe it is related really to Android Build Tollchain. I have opened a bug for this in 26 March and they have reviewed it :

https://issuetracker.google.com/issues/129323351

I am using latest Android Studio 3.5 Canary 9. @SUPERCILEX what Android Studio version do you use ? I mean this is happening in every version since latest coroutine release or only to 3.5 canary 9 version ?

Dope. And I've tried going back to alpha 6 I think. Still broken so it was definitely introduced by coroutines. Still seems like a tooling bug though. 🤷‍♂️

@SUPERCILEX , i understand , thanks for saving time not leaving me to downgrade too :D :D ... It will be fixed don't worry, it is just a very minor issue. I downgrade to 1.1.1 of coroutines but needed to fix this just for curiosity to test how the new version works ....

And some bug are normal, it is just Alpha version.
Best Regards, if they reply me to the bug report on Google i will reply back here to you to let you know, or just star that issue to stay updated

@SUPERCILEX , thanks for providing Google with open source project, it is really important and they will solve this for sure in this way. I can't share mine because is Close Source, so thank you for supporting !
Best Regards

@SUPERCILEX , i have solved id by adding this in my app gradle file

configurations {
        compile.exclude group: 'org.jetbrains.kotlinx', module: 'atomicfu-common'
    }

Same problem with version 1.2.0-alpha on my side.
Here's the error:

> Task :sample:mergeDebugJavaResource FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':sample:mergeDebugJavaResource'.
> 1 exception was raised by workers:
  com.android.builder.merge.DuplicateRelativeFileException: More than one file was found with OS independent path 'META-INF/atomicfu.kotlin_module'

And here's a permalink to a reproducing project: https://github.com/LouisCAD/Splitties/tree/e2389213a82aa91ca4ecf4a05fc67438e7c5ffd0
You can try it by just running ./gradlew :sample:assembleDebug.

Also, as @kherlopian2 said, adding this in the android { ... } block in build.gradle.kts can workaround that issue:

android {
    ...
    packagingOptions {
        pickFirst("META-INF/atomicfu.kotlin_module")
    }
    ...
}

@eakteam doesn't that break things at runtime though?

@SUPERCILEX , No, for me everything is running OK. There are 2 modules in group org.jetbrains.kotlinx

Remember to exclude only atomicfu-common module

Thanks for the reproducer and possible workarounds!
kotlin_module file is generated and used by the compiler, so we have no control over it.

This issue will be solved in 1.3.40 on the compiler side: https://youtrack.jetbrains.com/issue/KT-30344
And in AS independently: https://issuetracker.google.com/issues/125696148

I will leave the issue open for a while to make it easier for users to find a workaround.

If you're using Gradle you can specify archivesBaseName to generate modules with different names (and thus different .kotlin_module file names) to avoid collisions.

I don't understand why this is not solved yet in alpha-2 but we should use still the workaround ?

The problem is not in this library

On Thu, Apr 4, 2019 at 1:00 PM Emin Kokalari notifications@github.com
wrote:

I don't understand why this is not solved yet in alpha-2 but we should
use still the workaround ?


You are receiving this because you commented.

Reply to this email directly, view it on GitHub
https://github.com/Kotlin/kotlinx.coroutines/issues/1064#issuecomment-479980792,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEERzQ0rP37b42B5isGcijKA54IHxuks5vdi-8gaJpZM4cUGtN
.

Hmmmm, but this can contains in the aar the workaround to simplify things for new users, than after it is finally solved can edit back ... Anyway just my thoughts.

android {
    ...
    packagingOptions {
        pickFirst("META-INF/atomicfu.kotlin_module")
    }
    ...
}

Can confirm this worked for me^.

This issue is still happening with latest Kotlin 1.3.30 and latest Coroutines 1.2.0.
I don't know if should be fixed by next Android Studio version or by Kotlin or Coroutines library
We still need to implement the workarounds to skip the failure about duplicate entry

This issue is still happening with latest Kotlin 1.3.30 and latest Coroutines 1.2.0.

It was told before that it is not the library issue and that on Kotlin side it will be fixed in 1.3.40 and in AS 3.5 Canary 12.

@qwwdfsad , sorry i have missed that comment 😊.
Thanks for confirming it !

It looks that is a side-effect of leaked atomicfu dependency. atomicfu.kotlin_module will disappear in version 1.2.1. See #1120

packagingOptions {
pickFirst 'META-INF/kotlinx-io.kotlin_module'
pickFirst 'META-INF/atomicfu.kotlin_module'
pickFirst 'META-INF/kotlinx-coroutines-io.kotlin_module'
}

packagingOptions {
        pickFirst 'META-INF/kotlinx-io.kotlin_module'
        pickFirst 'META-INF/atomicfu.kotlin_module'
        pickFirst 'META-INF/kotlinx-coroutines-io.kotlin_module'
    }

that worked with me.

that worked with me (kotlin 1.3.30 + coroutines1.2.0) too, thanks.

@elizarov @qwwdfsad After upgrading to kotlin-v1.3.31 & coroutine-1.2.1, the leak of "atomicfu.kotlin_module" is fixed, but the leak of "kotlinx-coroutines-core.kotlin_module" is still there

Reproduce

git clone https://github.com/Sunbreak/notepad-sdk-mpp
cd androidSample && ./gradlew assembleDebug

By adding below line resolve issue

exclude 'META-INF/atomicfu.kotlin_module'

packagingOptions {
        pickFirst 'META-INF/kotlinx-io.kotlin_module'
        pickFirst 'META-INF/atomicfu.kotlin_module'
        pickFirst 'META-INF/kotlinx-coroutines-io.kotlin_module'
    }

that worked with me.

that worked for me

You could try
packagingOptions { exclude 'META-INF/atomicfu.kotlin_module' }

I still have to put pickFirst("META-INF/kotlinx-coroutines-core.kotlin_module") in the packagingOptions to be able to run Android instrumented tests from a multiplatform project as of Kotlin 1.3.50 and kotlinx.coroutines 1.3.1.

Do you have the same error com.android.builder.merge.DuplicateRelativeFileException: More than one file was found with OS independent path ... otherwise?

Still an issue for me in multiplatform project during project build, caused by this line:
commonMain.dependencies { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.2"
Message is More than one file was found with OS independent path 'META-INF/kotlinx-coroutines-core.kotlin_module'

AS ver. 3.5.2
Kotlin ver 1.3.50
Coroutines ver. 1.3.2

Workaround with packagingOptions doesn't work, probably packagingOptions are related to Android part, while this is a common one.

@mirokolodii Did you manage to solve it?

@linean Yes, issue was indeed fixed by packagingOptions, but it was required to put it into my app module instead multiplatform one, even though there are no dependencies to coroutines in app module.
Please note that I've also added pickFirst 'META-INF/ktor-*', as I had similar issue with Ktor library.
android { packagingOptions { pickFirst 'META-INF/kotlinx-io.kotlin_module' pickFirst 'META-INF/atomicfu.kotlin_module' pickFirst 'META-INF/kotlinx-coroutines-io.kotlin_module' pickFirst 'META-INF/kotlinx-coroutines-core.kotlin_module' pickFirst 'META-INF/kotlinx-serialization-runtime.kotlin_module' pickFirst 'META-INF/ktor-*' } }

@linean Yes, issue was indeed fixed by packagingOptions, but it was required to put it into my app module instead multiplatform one, even though there are no dependencies to coroutines in app module.
Please note that I've also added pickFirst 'META-INF/ktor-*', as I had similar issue with Ktor library.

android {
packagingOptions {
        pickFirst 'META-INF/kotlinx-io.kotlin_module'
        pickFirst 'META-INF/atomicfu.kotlin_module'
        pickFirst 'META-INF/kotlinx-coroutines-io.kotlin_module'
        pickFirst 'META-INF/kotlinx-coroutines-core.kotlin_module'
        pickFirst 'META-INF/kotlinx-serialization-runtime.kotlin_module'
        pickFirst 'META-INF/ktor-*'
    }
}

hello @mirokolodii , I have the same problem in my kotlin multiplatform project, so, we can only solve the problem by adding endless pickFirst statement in packagingOptions block? Any better way?

Do you have the same error com.android.builder.merge.DuplicateRelativeFileException: More than one file was found with OS independent path ... otherwise?

@qwwdfsad No, I don't.

@linean Yes, issue was indeed fixed by packagingOptions, but it was required to put it into my app module instead multiplatform one, even though there are no dependencies to coroutines in app module.
Please note that I've also added pickFirst 'META-INF/ktor-*', as I had similar issue with Ktor library.

android {
packagingOptions {
        pickFirst 'META-INF/kotlinx-io.kotlin_module'
        pickFirst 'META-INF/atomicfu.kotlin_module'
        pickFirst 'META-INF/kotlinx-coroutines-io.kotlin_module'
        pickFirst 'META-INF/kotlinx-coroutines-core.kotlin_module'
        pickFirst 'META-INF/kotlinx-serialization-runtime.kotlin_module'
        pickFirst 'META-INF/ktor-*'
    }
}

hello @mirokolodii , I have the same problem in my kotlin multiplatform project, so, we can only solve the problem by adding endless pickFirst statement in packagingOptions block? Any better way?

No idea to be honest. I expect they will fix it eventually, but for now I've just added those things and forgot about them.

See the recent problem with ktor dependency: https://github.com/Kotlin/kotlinx.coroutines/issues/1797 It will get fixed in the next release (already in develop)

I'm getting this error while generating signed debug apk:

Entry name 'META-INF/lifecycle-livedata-ktx_release.kotlin_module' collided

Anyone have possible solution for it. @elizarov ?

@AliAzaz This is not related to kotlinx.coroutines, and the solution is already in the comments here (pickFirst or exclude).

This is a bug in AGP (the Android Gradle Plugin), that is fixed since its version 7.0.0-alpha01, so you can upgrade from version 4.x if you are ready to test the next AGP and Android Studio 2020.3.1 early.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Pitel picture Pitel  ·  3Comments

elizarov picture elizarov  ·  3Comments

ZakTaccardi picture ZakTaccardi  ·  3Comments

iTanChi picture iTanChi  ·  3Comments

petersamokhin picture petersamokhin  ·  3Comments