realm-java: [Kotlin] annotation processor throws if the realm plugin is applied after kotlin
Goal
Use a RealmList<String> in Kotlin
Expected Results
I’m able to use a (Kotlin) String in a RealmList
Actual Results
Realm can’t use Kotlin strings, saying:
Error:Element type of RealmList must be a class implementing ‘RealmModel’ or one of the ‘java.lang.String’, ‘byte[]’, ‘java.lang.Boolean’, ‘java.lang.Long’, ‘java.lang.Integer’, ‘java.lang.Short’, ‘java.lang.Byte’, ‘java.lang.Double’, ‘java.lang.Float’, ‘java.util.Date’.
Also, using java.lang.String
in a Kotlin file doesn’t fix the error.
Steps & Code to Reproduce
- Setup new project
- Create realm object
- Add
var list : RealmList<String> = RealmList()
See the error shown above
Version of Realm and tooling
Realm version(s): 4.0.0
Realm sync feature enabled: no
Android Studio version: 3.0.0RC1
Which Android version and device: n/a
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 19 (11 by maintainers)
@Marcel50506
The problem is caused by the order of applied plugins:
Change it to:
Will solve the issue.
But it feels something is not right there since i got:
when the problem happens
I guess something needs to be updated in the realm plugin.
using
classpath "io.realm:realm-gradle-plugin:4.0.0"
and plugins
And following class
My code compiles just fine with Kotlin? 😕
We got the same issue while using kapt3 ("apply “kotlin-kapt”), and it’s gone using kapt1 (which should be deprecated)Forget what I said, i messed up, the issue we got was when we tried with List<String> instead of RealmList<String>@Zhuinden
This doesn’t make a difference