Duplicate files copied in APK META-INF/library_release.kotlin_module

I recently added two Android libraries through JitPack and I have the following error:

Duplicate files copied in APK META-INF/library_release.kotlin_module

I've cleared the cached and I've tried excluding the module using

exclude group: 'org.jetbrains'

and

exclude group: 'org.jetbrains.kotlin'

but neither seems to resolve the issue. Is there any way to stop the kotlin stdlib from being added through JitPack? Oddly, other libraries like DbFlow don't have this issue, though I don't see anything special about their setup (other than that it isn't through JitPack)

You should add this to the build.gradle file of your app inside the android tag

packagingOptions {
    exclude 'META-INF/library_release.kotlin_module'
}

More than one file was found with OS independent path 'META-INF , More than one file was found with OS independent path /44509608/duplicate-​files-copied-in-apk-meta-inf-library-release-kotlin-module  Save hard disk space by removing duplicate files - Duplicate Sweeper

As suggested in the post Kotlin M13 is out! by jetbrains:

Make sure these .kotlin_module files are not stripped by your packaging process.

So, we can't use exclude option to exclude this resource file from being generated.

As descripted in Kotlin M13 is out!, we should:

in Maven we use groupId and artifactId for module names, but you can say

<configuration>
    <moduleName>com.example.mymodule</moduleName>
</configuration>

in Gradle it’s project name + build task name, to customize:

compileKotlin {
    kotlinOptions.moduleName = "com.example.mymodule"    
}

This is my configuration for Android library project:

ext {
    GROUP_ID = 'custom.group.id'
    ARTIFACT_ID = 'artifactid'
}

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"

    compileOptions {
        kotlinOptions.freeCompilerArgs += ['-module-name', "$GROUP_ID.$ARTIFACT_ID"]
    }

    defaultConfig {
        ...
    }
    buildTypes {
        ...
    }
}

Resource file named META-INF/custom.group.id.artifactId.kotlin_module will be generated instead of META-INF/library_release.kotlin_module.No more duplicate files will be found.

You can read this post and this post for more information.

Fix Duplicate files copied in APK META-INF/library_release , Fix Duplicate files copied in APK META-INF/library_release.kotlin_module #284. unknown repository. drakeet:master unknown repository. @litangyu. Duplicate files copied in APK META-INF/library_release.kotlin_module I've cleared the cached and I've tried excluding the module using. exclude group: 'org.jetbrains' and. exclude group: 'org.jetbrains.kotlin' but neither seems to resolve the issue. Is there any way to stop the kotlin stdlib from being added through JitPack?

After looking at other conflicts, it seems like the resolution is

packagingOptions {
    pickFirst 'META-INF/library_release.kotlin_module'
}

under android in the app gradle.

This allows the apk to build

Duplicate files copied in APK Android - Can it be merged?, DuplicateFileException: Duplicate files copied in APK files and they both contained META-INF folder with library_release.kotlin_module file. DuplicateFileException: Duplicate files copied in APK META-INF/INDEX.LIST #94. DuplicateFileException: Duplicate files copied in APK META-INF/INDEX.LIST #94.

Disable META-INF/* generation in gradle android library kotlin , J'ai récemment ajouté deux bibliothèques Android par JitPack et j'ai l'erreur suivante: Duplicate files copied in APK META-INF/library_release.kotlin_module J'ai  Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more Android Studio: Duplicate files copied in APK assets

Disable META-INF/* generation in gradle android project, I recently added two Android libraries through JitPack and I have the following error: Duplicate files copied in APK META-INF/library_release.kotlin_module. Indeed, I have 2 libraries with this file, one of them is chucker: There is a way to fix this with packagingOptions: packagingOptions { exclude 'META-INF/library_release.kotlin_module' } However it seems that the root cause can be solved on the library, which is better because it avoids having everyone to add the exclude fix:

Les fichiers en double copiés dans APK META-INF/library_release , I check it again and find its my fault, using macOS rename doesn't see all file name, it became react-native-0.49.5.aar.zip, after I fixed this problem and put .aar again, android studio went wrong, the log is below:

Comments
  • Do you know if the file itself has any significance in the app? Or is it just there as info?
  • I never seen a problem excluding those META-INF files in Android. Btw i don't know Kotlin enough to be sure that this is useless at 100%. As i suggested in the other comment, you should try with exclude first, if it is working continue to use it (the app will be lighter by some KBs XD), if not switch to pickFirst ;)
  • Doesn't it mean that when we switch to different buildType or productFlavor the same error appears again because it generates files with new names?
  • leads to Kotlin classes not being recognized