如題
Class 'kotlin.jvm.JvmClassMappingKt' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler
Class 'kotlin.reflect.KClass' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler
應該是kotlin的版本導致的,用的是IDEA,kotlin版本是1.4.0-rc-release-IJ2019.3-2
出錯代碼,使用retrofit+json去post
kt主檔案
...
val api: Api = retrofit.create(Api::class.java)
...
Api.java
package com.example.plugin;
import com.example.plugin.net.*;
import retrofit2.http.Body;
import retrofit2.http.POST;
import retrofit2.Call;
public interface Api {
// 發送json資料形式的post請求,把網路請求介面的后半部分openapi/api/v寫在里面
// Get是請求資料物體類,Take接受資料物體類
//發送json資料形式的post請求,把網路請求介面的后半部分openapi/api/v寫在里面
//Get是請求資料物體類,Take接受資料物體類
@POST("openapi/api/v2")//接入圖靈
Call<Return_text> request(@Body Ask_text ask);
}
Ask_text和Return_text都是json to kotlin class 生成的kt檔案
也用了gradle
build.gradle
...
dependencies {
compileOnly 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
compile fileTree(dir:'/jars/',includes: ['*.jar'])
//implementation("com.squareup.okhttp3:okhttp:4.2.2")
implementation("com.squareup.retrofit2:retrofit:2.3.0")
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation "com.squareup.retrofit2:adapter-rxjava:2.3.0"
}
...
是不是implementation的一些版本和kotlin的版本不匹配啊....
uj5u.com熱心網友回復:
就是val api: Api = retrofit.create(Api::class.java)
這一行報錯
uj5u.com熱心網友回復:
應該是IDEA版本過低導致的 我先更新看看轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/16581.html
標籤:其他開發語言
