Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

duplicate entry: META-INF/myLibrary.kotlin_module

After updating to Android 3.0, getting Kotlin error:

Execution failed for task ':myLibrary:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug'.
> java.lang.RuntimeException: java.util.zip.ZipException: duplicate entry: META-INF/myLibrary.kotlin_module

This is my library buid.gradle file:

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

...

dependencies {
    api "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}

This is my project build.gradle

ext.kotlin_version = '1.1.51'
repositories {
    jcenter()
    mavenCentral()
    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
like image 665
Ilya Gazman Avatar asked Oct 29 '17 22:10

Ilya Gazman


3 Answers

This is so annoying, but running Clean Project fixed the problem for me.

like image 71
Ilya Gazman Avatar answered Nov 14 '22 11:11

Ilya Gazman


Try adding this to your build.gradle . in packagingOptions:

packagingOptions {
    ...
    exclude 'META-INF/rxkotlin.properties'
    exclude 'META-INF/rxkotlin_main.kotlin_module'
}
like image 2
Bernardo Rocha Avatar answered Nov 14 '22 10:11

Bernardo Rocha


Looks like a cache error (with kotlin) to me. Running gradle clean or gradle clear (not sure which is the right spelling, sorry, one of these should exist as a gradle task) and rebuilding should fix the error, because all files in cache will be deleted by the task and regenerated by the project build.

like image 1
liketechnik Avatar answered Nov 14 '22 10:11

liketechnik