Android项目使用OkHttp3的时候报错Static interface methods are only supported starting with Android N


  一个老的项目在引入OkHttp3最新版本3.13.1之后编译报错,信息如下

AGPBI: {“kind”:”error”,”text”:”Static interface methods are only supported starting with Android N (–min-api 24): okhttp3.Request okhttp3.Authenticator.lambda$static$0(okhttp3.Route, okhttp3.Response)”,”sources”:[{}],”tool”:”D8”}

去OkHttp官方看了一下3.13.1的release note,有一段信息如下

This release bumps our minimum requirements to Java 8+ or Android 5+. Cutting off old devices is a serious change and we don’t do it lightly! This post explains why we’re doing this and how to upgrade.
The OkHttp 3.12.x branch will be our long-term branch for Android 2.3+ (API level 9+) and Java 7+. These platforms lack support for TLS 1.2 and should not be used. But because upgrading is difficult we will backport critical fixes to the 3.12.x branch through December 31, 2020.

3.13.1这个版本最低版本需要Java8+或Android 5+支持,如果你需要兼容老设备,用之前的版本就行了,如果只是想编译通过,可以在gradle文件里面添加下面配置信息

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

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://11000011.com/?id=108

« 上一篇 下一篇 »

我要评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

主机推荐

  • 搬瓦工