KotlinJsonAdapterFactory未解决的引用。

8
我正在使用Kotlin构建Android应用程序,并使用Retrofit进行API调用,同时还使用Moshi。但是在构建Moshi时,它会提示“KotlinJsonAdapteryFactory - 未解决的引用”,并且我无法使用Moshi,因为它在此行中给出了一个错误。您有任何想法为什么会发生这种情况吗? 这些是我的Moshi依赖项:
    implementation("com.squareup.moshi:moshi:1.12.0")
    kapt "com.squareup.moshi:moshi-kotlin-codegen:1.12.0"
    implementation "com.squareup.retrofit2:converter-moshi:2.5.0" 

以下是构建 Moshi 和 Retrofit 的代码:

 private val moshi: Moshi = Moshi.Builder().addLast(KotlinJsonAdapterFactory()).build()
 val retrofit: Retrofit = Retrofit.Builder()
        .client(getLoggingHttpClient())
        .baseUrl(BASE_URL)
        .addConverterFactory(MoshiConverterFactory.create(moshi))
        .build()
1个回答

27

1
好的,它起作用了! - FrensisXh

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接