I want to add an interface to a given class and lazy-load its values.
Compile-time error "error: cannot find symbol"
I'm using the gradle-plugins kotlin-kapt and realm-android and these two combined cause this.
My demo-project (github.com/hardysim/bylazy-demo) does not compile in the current state and starts working when you remove either kotlin-kapt or realm-android.
There is no usage of realm but adding the plugin.
This uses to work with Kotlin 1.2.71 but is now broken with Kotlin 1.3.0.
Maybe it's related to kotlin / kapt and not to realm but because the combination of both breaks things I wanted to look here for help as well.
This originates from https://github.com/lisawray/groupie/issues/218 and https://stackoverflow.com/questions/53168385/
Realm version(s): 5.8.0
Realm Sync feature enabled: No
Android Studio version: 3.2.1
Android Build Tools version: 28
Gradle version: 4.10.2
Thank you for the project.
I can reproduce the error locally as well.
I'm not entirely sure it is Realm related though as that code shouldn't be something we touch in any way. That said, we do have a bytecode transformer running that by some accident might touch the code, but why it should break because you upgraded Kotlin is beyond me.
One observation:
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
Makes the project compile
Upgrading https://github.com/realm/realm-java/tree/master/examples/kotlinExample to Kotlin 1.3 also works fine. So something is definitely fishy somewhere.
Hey - looks like you forgot to add a T:* label - could you please add one?
I think I managed to isolate the issue.
It appears that kapt is broken in 1.3.0 in your particular use case.
I tried removing the Realm plugin and setting the dependencies as described here: https://realm.io/docs/java/latest/#how-do-i-customize-dependecies-defined-by-the-realm-gradle-plugin
As soon as I disable:
kapt "io.realm:realm-annotations-processor:$realm_version"
The project compiles fine.
I'll verify this with another annotation processor and then file a bug with Kotlin
EDIT: Verified with only kapt 'com.jakewharton:butterknife-compiler:9.0.0-rc1' as well
I created https://youtrack.jetbrains.net/issue/KT-28053 for tracking this. I'll keep this issue open until we get an answer from JetBrains. Also, so other people upgrading can more easily find the issue.
I'll update the docs with a note of this.
Ok, it seems that they'll fix it in 1.3.20.
Plus, I was able to workaround this by specifying the type explicitly:
private val foo : Foo by lazy { }
See https://github.com/hardysim/bylazy-demo/commit/de3f294bc54958c9e5f4c590d6ab39aadd3eb32c
Most helpful comment
Ok, it seems that they'll fix it in 1.3.20.
Plus, I was able to workaround this by specifying the type explicitly:
See https://github.com/hardysim/bylazy-demo/commit/de3f294bc54958c9e5f4c590d6ab39aadd3eb32c