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 have
kapt { generateStubs = true }
in my build gradle code.
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