I am trying to convert a android project written in java to kotlin. My greendao class have been generated by anytime i build i get a Unresolved reference: DaoSession
error message. I havekapt { generateStubs = true }
in my build gradle code.
Move your greendao
plugin before the kotlin
plugin in your app build.gradle like below:
apply plugin: 'org.greenrobot.greendao'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android'
This is caused by that Greendao generate DaoSession and other Dao files at a default path:"app/build/generated/source/greendao/", which cannot be found by kotlin.
So you just need to change the Dao path by adding this code to your module Gradle file:
greendao {
targetGenDir 'src/main/java'
}
Then, you can find the Dao files like DaoSesson.java are generated in your project path 'src/main/java'. Now Kotlin can find the DaoSession.
Hope can help.
Reference: https://github.com/greenrobot/greenDAO/issues/352
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With