I am trying to use Moshi's Kotlin codegen to get annotation support in Kotlin. Despite following the instructions carefully in the moshi codegen documentation, the annotation JsonClass
in @JsonClass(generateAdapter = true)
is not recognized and I am getting the following error:
error: incompatible types: NonExistentClass cannot be converted to Annotation@error.NonExistentClass()
My app build.gradle
file is as follows:
...
apply plugin: 'kotlin-kapt'
android {
...
}
dependencies {
...
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-moshi:2.5.0'
kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.8.0'
}
The @JsonClass
annotation is recognized when I add
implementation("com.squareup.moshi:moshi-kotlin:1.8.0")
.
However, the moshi reflection documentation indicates that this dependency is only required if using reflection instead of codegen.
Any idea what I'm missing? Thanks!