I want to run an Android Test for a Kotlin class that uses Realm
Error:Execution failed for task ':data:compileDebugAndroidTestJavaWithJavac'.
java.lang.NoClassDefFoundError:
org/jetbrains/kotlin/annotation/AnnotationProcessorWrapper
Realm version(s): 2.3.0 (2.2.2 works)
Realm sync feature enabled: no
Android Studio version: 2.2.3
Kotlin: 1.0.6
I've created a minimum working (well, failing) example, a brand new Android Kotlin project with just the 2 lines in the build.gradle files for Realm added to it: https://github.com/zsmb13/Realm230withKotlin
@ziggy42 @zsmb13 I reproduced the issue.
And I found a work-around, which is adding apply plugin: 'kotlin-kapt' to app/build.gradle.
I added it right before apply plugin: 'realm-android'.
I think that the root cause of this error is https://github.com/realm/realm-java/pull/4022/files
From 2.3.0, we started to add kaptAndroidTest when the project is using Kotlin.
I think we need to check if kaptAndroidTest exists.
Does this work-around is good for your environment?
This works for me, thanks!
Maybe it could be added to the Java install notes somewhere/somehow? Or perhaps to the kotlin example?
Works for me, too.
Only Kotlin 1.0.6 has this problem.
1.0.4 and 1.0.5 works well without kotlin-kapt plugin
This issue seems a bug of kotlin 1.0.6.
kaptAndroidTest is defined without kotlin-kapt plugin, but when we use it, 馃敟
Most helpful comment
@ziggy42 @zsmb13 I reproduced the issue.
And I found a work-around, which is adding
apply plugin: 'kotlin-kapt'toapp/build.gradle.I added it right before
apply plugin: 'realm-android'.I think that the root cause of this error is https://github.com/realm/realm-java/pull/4022/files
From 2.3.0, we started to add
kaptAndroidTestwhen the project is using Kotlin.I think we need to check if
kaptAndroidTestexists.Does this work-around is good for your environment?