小编Sha*_*hra的帖子

从retrofit2调用Web请求时如何解决致命异常?

我正在尝试向 API 调用 GET 请求,但改造会引发 FATAL EXCEPTION

错误

2019-12-18 22:26:55.733 27892-29449/com.shashank.foe E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
    Process: com.shashank.foe, PID: 27892
    java.lang.BootstrapMethodError: Exception from call site #1 bootstrap method
        at retrofit2.DefaultCallAdapterFactory$ExecutorCallbackCall$1.onResponse(DefaultCallAdapterFactory.java:76)
        at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:129)
        at okhttp3.RealCall$AsyncCall.run(RealCall.kt:138)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.NoClassDefFoundError: Invalid descriptor: VLLLLLZ.
        at retrofit2.DefaultCallAdapterFactory$ExecutorCallbackCall$1.onResponse(DefaultCallAdapterFactory.java:76) 
        at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:129) 
        at okhttp3.RealCall$AsyncCall.run(RealCall.kt:138) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 
        at java.lang.Thread.run(Thread.java:764) 
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

主活动.kt

val retrofitService = RetrofitService()
val userApi = retrofitService.createService(UserApi::class.java)

val call = userApi.get()

call.enqueue(object : Callback<Temp> {
   override fun onResponse(call: …
Run Code Online (Sandbox Code Playgroud)

api rest android kotlin retrofit2

4
推荐指数
1
解决办法
2214
查看次数

标签 统计

android ×1

api ×1

kotlin ×1

rest ×1

retrofit2 ×1