通过这个我们知道了okhttp3 从3.13.0之后不再支持android5.0以下的系统了。
如果你用了implementation("com.squareup.okhttp3:okhttp:latest.release")就会出现
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,有一段信息如下
我们通过okhttp(github)网站上看到了这么一段话
OkHttp works on Android 5.0+ (API level 21+) and on Java 8+.
OkHttp has one library dependency on [Okio](https://github.com/square/okio/), a small library for high-performance I/O. It works with either Okio 1.x (implemented in Java) or Okio 2.x (upgraded to Kotlin).
We highly recommend you keep OkHttp up-to-date. As with auto-updating web browsers, staying current with HTTPS clients is an important defense against potential security problems. [We track](https://github.com/square/okhttp/wiki/TLS-Configuration-History) the dynamic TLS ecosystem and adjust OkHttp to improve connectivity and security.
OkHttp uses your platform's built-in TLS implementation. On Java platforms OkHttp also supports [Conscrypt](https://github.com/google/conscrypt/), which integrates BoringSSL with Java. OkHttp will use Conscrypt if it is the first security provider:
Security.insertProviderAt(Conscrypt.newProvider(), 1);
The OkHttp 3.12.x branch supports 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](https://github.com/square/okhttp/tree/okhttp_3.12.x) through December 31, 2020.
翻译:
OkHttp工作在Android 5 +(API级别21 +)和Java 8 +上。
OkHttp有一个库依赖于[Oki](http://Github.com/方/ Oki/),它是一个用于高性能I/O的小库,它与Okio 1 .x(Java实现)或OKIO 2。x(升级到Kotlin)一起工作。
我们强烈建议您保持OKHTTP最新。与自动更新Web浏览器一样,保持HTTPS客户端的最新状态是防止潜在安全问题的重要防御措施。[我们跟踪](https://github.com/square/okhttp/wiki/tls配置历史)动态TLS生态系统并调整okhttp以提高连接性和安全性。
OKHTTP使用平台的内置TLS实现。在Java平台上,OKHTTP还支持了[CONSCRYPT](http://Github.com/谷歌/CONSCRYPT),它集成了BRIGIN SSL和Java。如果是第一个安全提供者,OKHTTP将使用Conscrypt:
security.insertProviderAt(conscrypt.newProvider(),1);
OKHTTP 3.12 .x分支支持Android 2.3 +(API级别9 +)和Java 7 +。这些平台不支持TLS 1.2,因此不应使用。但是因为升级很困难,我们将把关键的修复移植到[3.12.x分支(https://github.com/square/okhttp/tree/okhttp_3.12.x)到2020年12月31日。
3.13.x 这个版本最低版本需要Java8+和Android 5+支持,如果你需要兼容老设备,用之前的版本就行了,如果只是想编译通过,可以在gradle文件里面添加下面配置信息
compileOptions {
targetCompatibility = "8"
sourceCompatibility = "8"
}
网友评论