But it ended up, that not only Nullable.class and NotNull.class were duplicates, but also classes from org/intellij/lang/annotations/.
After I added five classes it still crashed. Is there a better way to get rid of this problem, by not adding every class manually that causes this exception?
UPDATE (02.02.16)
As I worked a bit on the problem, I found out that for my project the relevant annotation classes are NonNls.class and Contract.class that are missing, if I remove org.jetbrains:annotations-java5:15.0. They are not in kotlin-runtime, but in the Jetbrains annotation dependency. How can I add it without adding the Jetbrains annotation dependency again? Or what about adding the whole library to Kotlin?
Take a look at my reply half a year ago. That is in an android context, but there is nothing android-specific to the solution:
I see, that is where the stackoverflow answer comes from as well. The amount of classes should be fairly limited so I would stick with manually enumerating them. Of course you could configure gradle with a filter (instead of manual exclusions) and in that filter check for containment of the name in kotlin-stdlib → better yet, cache this somehow as it’s not really fast.
You should examine from which dependencies these two annotation classes are coming from, because kotlin-runtime bundles only those 4 annotations, and neither Flow nor Identifier are in that list.
Most likely the conflict is between 'org.jetbrains:annotations-java5:15.0' and 'org.jetbrains:annotations:15.0'.
You can use dependenies gradle task to inspect the dependency graph of your project.
Thanks for your answer. I only have 'org.jetbrains:annotations-java5:15.0' as a dependency and not the other one. I updated my question, because I’m at the point to drop the whole dependency.
@praveenpro It looks like you have class org.intellij.lang.annotations.Flow coming from several jars. One of them is coming from org.jetbrains:annotations maven artifact which is a transitive dependency of org.jetbrains.kotlin:kotlin-stdlib-jre7 and to find the other, you can run gradlew dependency to show the dependency graph of your project.
Then you may want to exclude one of the conflicting artifacts: java - How do I exclude all instances of a transitive dependency when using Gradle? - Stack Overflow