Realm-java: AndroidTest for a Kotlin class does not compile

Created on 20 Jan 2017  路  6Comments  路  Source: realm/realm-java

Goal

I want to run an Android Test for a Kotlin class that uses Realm

Actual Results

Error:Execution failed for task ':data:compileDebugAndroidTestJavaWithJavac'.
 java.lang.NoClassDefFoundError:
org/jetbrains/kotlin/annotation/AnnotationProcessorWrapper

Version of Realm and tooling

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

T-Bug

Most helpful comment

@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?

All 6 comments

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, 馃敟

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mithrann picture mithrann  路  3Comments

nolanamy picture nolanamy  路  3Comments

bryanspano picture bryanspano  路  3Comments

CNyezi picture CNyezi  路  3Comments

wyvern610 picture wyvern610  路  3Comments