【发布时间】:2021-12-26 23:44:00
【问题描述】:
我添加了 OkHttpProfilerInterceptor 来拦截 HTTP 请求。 但是自从我将我的 Target SDK 升级到 30 后,它在这里崩溃了。
if (HelperMethods.isDebug()) {
OkHttpClient client = new OkHttpClient().newBuilder().addInterceptor(new OkHttpProfilerInterceptor()).build();
AndroidNetworking.initialize(getApplicationContext(), client);
} else
AndroidNetworking.initialize(getApplicationContext());
错误日志
Caused by: java.lang.IllegalStateException: Expected Android API level 21+ but was 30
at okhttp3.internal.platform.AndroidPlatform$Companion.buildIfSupported(AndroidPlatform.kt:370)
at okhttp3.internal.platform.Platform$Companion.findPlatform(Platform.kt:204)
at okhttp3.internal.platform.Platform$Companion.access$findPlatform(Platform.kt:178)
at okhttp3.internal.platform.Platform.<clinit>(Platform.kt:179)
at okhttp3.OkHttpClient.<init>(OkHttpClient.kt:211)
at okhttp3.OkHttpClient.<init>(OkHttpClient.kt:204)
我不知道为什么会这样,因为当我的目标版本是 29 时它工作正常,因为 playstore 现在不允许 sdk 29,所以我被困在这里。
我尝试更新 okhttp 库版本,但没有成功。
【问题讨论】:
标签: android android-studio okhttp android-sdk-tools