LoginSignup
2
1

More than 5 years have passed since last update.

apkをビルドできない java.util.zip.ZipException: duplicate entry

Last updated at Posted at 2017-10-11

KotlinのプロジェクトにAdobe Creative SDKを導入しapkを作成しようとしたところ以下のエラーでハマった。

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/intellij/lang/annotations/Identifier.class

Identifier.classでgrepすると以下の用にannotations-12.0.jarとannotation-13.jarが使用されようとしていた。

$./gradlew assembleDebug --stacktrace --info | grep Identifier.class

addJar(/Users/ユーザー名/.gradle/caches/modules-2/files-2.1/com.intellij/annotations/12.0/bbcf6448f6d40abe506e2c83b70a3e8bfd2b4539/annotations-12.0.jar): entry org/intellij/lang/annotations/Identifier.class
addJar(/Users/ユーザー名/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar): entry org/intellij/lang/annotations/Identifier.class

古い(であろう)12の方のcom.intellijのannotationsを次のように除外設定することで無事ビルドできるようになりました。

appモジュールのbuild.gradle
android {
    // 中略
    configurations.all {
        exclude group: 'com.intellij', module:'annotations'
    }
}

なんかいつもgradle周りは行き当たりばったりの解決で理解が深まらないぜ!
まぁしかたないが、記録に残せば何か変わるかも。

参考
https://medium.com/@terrakok/how-to-fix-gradle-build-error-java-util-zip-zipexception-duplicate-entry-83d102038056

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1