okhttp异常处理

在使用OKhttp,创建OkHttpClient请求网络时,会抛出异常

java.lang.BootstrapMethodError: Exception from call site #5 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.amazonaws.transcribestreaminghttpclient.MainActivity.<init>(MainActivity.java:28)
    at java.lang.Class.newInstance(Native Method)
    at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:69)
    at android.support.v4.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:43)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1215)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2831)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)

对于这中问题处理,JakeWharton大神给出了答案,就是在build.gradle文件里添加

android {
    compileOptions {
        targetCompatibility = "8"
        sourceCompatibility = "8"
    }
}

重新运行就ok了

参考https://github.com/square/okhttp/issues/4597

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值