Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

455
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda