Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

454
Views
Difficulty using Moshi's Kotlin codegen

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!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

@JsonClass is a type in the standard Moshi artifact. Retrofit's converter-moshi artifact brings in Moshi transitively but does not have the latest version of Moshi. Specify implementation("com.squareup.moshi:moshi:1.8.0").

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!