美文网首页
记使用OkHttp遇到的问题

记使用OkHttp遇到的问题

作者: 阳心扬涵neu | 来源:发表于2019-02-13 11:40 被阅读0次

1、  java.lang.BootstrapMethodError,使用的是okhttp3

2019-02-13 11:37:03.244 23271-23271/com.example.****.myandroidproject E/AndroidRuntime: FATAL EXCEPTION: main

    Process: com.example.****.myandroidproject, PID: 23271

    java.lang.BootstrapMethodError: Exception from call site #1 bootstrap method

        at okhttp3.internal.Util.<clinit>(Util.java:87)

        at okhttp3.internal.Util.immutableList(Util.java:234)

        at okhttp3.OkHttpClient.<clinit>(OkHttpClient.java:127)

        at com.example.yangxiaochun.myandroidproject.activity.OkHttpDemoActivity.initNetWork(OkHttpDemoActivity.java:34)

        at com.example.yangxiaochun.myandroidproject.activity.OkHttpDemoActivity.onCreate(OkHttpDemoActivity.java:29)

        at android.app.Activity.performCreate(Activity.java:7009)

        at android.app.Activity.performCreate(Activity.java:7000)

        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)

        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)

        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)

        at android.app.ActivityThread.-wrap11(Unknown Source:0)

        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)

        at android.os.Handler.dispatchMessage(Handler.java:106)

        at android.os.Looper.loop(Looper.java:164)

        at android.app.ActivityThread.main(ActivityThread.java:6494)

        at java.lang.reflect.Method.invoke(Native Method)

        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)

        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

    Caused by: java.lang.NoClassDefFoundError: Invalid descriptor: ()Ljava/lang/Throwable;.

        at okhttp3.internal.Util.<clinit>(Util.java:87) 

        at okhttp3.internal.Util.immutableList(Util.java:234) 

        at okhttp3.OkHttpClient.<clinit>(OkHttpClient.java:127) 

        at com.example.yangxiaochun.myandroidproject.activity.OkHttpDemoActivity.initNetWork(OkHttpDemoActivity.java:34) 

        at com.example.yangxiaochun.myandroidproject.activity.OkHttpDemoActivity.onCreate(OkHttpDemoActivity.java:29) 

        at android.app.Activity.performCreate(Activity.java:7009) 

        at android.app.Activity.performCreate(Activity.java:7000) 

        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214) 

        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731) 

        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 

        at android.app.ActivityThread.-wrap11(Unknown Source:0) 

        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 

        at android.os.Handler.dispatchMessage(Handler.java:106) 

        at android.os.Looper.loop(Looper.java:164) 

        at android.app.ActivityThread.main(ActivityThread.java:6494) 

        at java.lang.reflect.Method.invoke(Native Method) 

        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 

        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 

解决方式:在build.gradle中添加以下代码Java8的新特性

compileOptions{

    sourceCompatibility JavaVersion.VERSION_1_8

targetCompatibility JavaVersion.VERSION_1_8

}

相关文章

网友评论

      本文标题:记使用OkHttp遇到的问题

      本文链接:https://www.haomeiwen.com/subject/gxbsdttx.html