Kotlin,Java,multidex,Dagger 2,Butterknife and Realm: transformClassesWithJarMergingForDebug: duplicate entry: org/jetbrains/annotations/NotNull.class

扶醉桌前 提交于 2019-12-05 10:07:17

Try to delete: compile 'org.jetbrains:annotations-java5:15.0'. If it won't work, follow these steps:

Go to your app/build.gradle file and add:

configurations {
    cleanedAnnotations

    compile.exclude group: 'org.jetbrains' , module:'annotations'
}

Change

compile 'org.jetbrains:annotations-java5:15.0'

with

 compile files("${buildDir}/libs/annotations-cleaned.jar") { builtBy 'cleanAnnotationsJar' }
    cleanedAnnotations 'org.jetbrains:nnotations-java5:15.0'

Finally add:

task cleanAnnotationsJar(type:Jar) {
    configurations.cleanedAnnotations.each { f ->
        from zipTree(f)
    }
    archiveName = "annotations-cleaned.jar"
    exclude 'org/jetbrains/annotations/NotNull.class'
    exclude 'org/jetbrains/annotations/Nullable.class'
}

Check: https://discuss.kotlinlang.org/t/duplicate-classes-in-kotlin-runtime-and-com-intellij-annotations/154/3

I change compile ("org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version") to compile ("org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version") { exclude group: 'org.jetbrains', module: 'annotations' } ,It works。 have a try!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!