最近升级了Android studio,导致项目好多报错,这是其中的一个OKhttp很坑的错误。
保存信息如下:
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Failed to process D:\gradle\caches\modules-2\files-2.1\com.squareup.okhttp3\okhttp\3.14.1\67612a22d4b8f33c55263b188bf5a72774d06d18\okhttp-3.14.1.jar
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
Caused by: com.android.tools.r8.utils.AbortException: Error: Static interface methods are only supported starting with Android N (--min-api 24): okhttp3.Request okhttp3.Authenticator.lambda$static$0(okhttp3.Route, okhttp3.Response)
解决办法:
在主项目的build.gradle中添加JDK1.8的支持
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}