Duplicate org.jetbrains.annotations when adding kotlin to android project

I added a hello world kotlin activity living next to my java sources and just trying to compile on the command line. It even failed to build when I was missing the layout I was trying inflate in the kotlin activity. So all that appears to be working.

However the build fails in the packaging step:

Execution failed for task ‘:project:packageAllDebugClassesForMultiDex’.
> java.util.zip.ZipException: duplicate entry: org/jetbrains/annotations/Nullable.class

I have tried all combinations of kotlin 0.11.91.x and android plugin 1.1.x -> 1.2.x

My dependencies are as follows and I was wondering what additional information I need to provide to get this resolved:

buildscript {
  ext.kotlin_version = ‘0.11.91.4’

  repositories {
  maven { url ‘https://maven.fabric.io/public’ }
  mavenCentral()
  }
  dependencies {
  classpath ‘io.fabric.tools:gradle:1.18.0’
  classpath ‘com.android.tools.build:gradle:1.2.2’
  classpath ‘com.jakewharton.sdkmanager:gradle-plugin:0.12.0’
  classpath ‘com.neenbedankt.gradle.plugins:android-apt:1.4’
  classpath “org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}”
  }
}

dependencies {
  // …
  compile “org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}”
  // …
}

Found out that another library we were using included com.intellij.annotations in it

Changing it to:

compile (‘com.wefika:flowlayout:0.4.0’) {
  exclude group: ‘com.intellij’
}

Fixed the build.

1 Like