Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android OkHttp(s)URLConnection类在4.9.0版本中不可用_Android_Android Gradle Plugin_Okhttp - Fatal编程技术网

Android OkHttp(s)URLConnection类在4.9.0版本中不可用

Android OkHttp(s)URLConnection类在4.9.0版本中不可用,android,android-gradle-plugin,okhttp,Android,Android Gradle Plugin,Okhttp,我在Android项目的gradle文件中使用com.squareup.okhttp3:okhttpurlconnection:3.13.1jar作为依赖项,如下所示用于获取urlconnection protected URLConnection getStandardHTTPURLConnection(URL url) throws IOException { return new OkHttpURLConnection(url, builder.cookieJar(new Java

我在Android项目的gradle文件中使用com.squareup.okhttp3:okhttpurlconnection:3.13.1jar作为依赖项,如下所示用于获取urlconnection

protected URLConnection getStandardHTTPURLConnection(URL url) throws IOException {
    return new OkHttpURLConnection(url, builder.cookieJar(new JavaNetCookieJar(CookieHandler.getDefault())).build());
}
因此,我将jar更新为4.9.0,并意识到,OkHttpURLConnection不可用。它导致运行时出现noClassDefinition异常。那么,还有什么选择呢?它是否已弃用或移动到另一个引擎盖下

以下是我的进口商品

import okhttp3.internal.huc.OkHttpURLConnection;
import okhttp3.internal.huc.OkHttpsURLConnection;
好心的建议。

所以我想他们是在4.x上被删除的

Apache HTTP客户端和HttpURLConnection API已被弃用。他们 继续像往常一样工作,但我们正在把一切都转移到 新的OKHTTP3API。okhttp apache和okhttp URL连接 模块只能用于加速到OkHttp的转换 请求/响应API。这些不推荐使用的模块将在 即将发布的OKHTTP3.x版本


OkHttp 3.14.0发行说明中提到了一个可粘贴的兼容性实现


好的,有没有关于如何替换它的想法?降级到系统内置的HttpURLConnection或升级到OkHttp的请求/响应API。或者,如果您想为自己争取一些时间,请粘贴上面变更日志中引用的要点<代码>okhttp3.internal.huc.OkHttpURLConnection.d():[0x95]无法从类型为未解析引用p1.l0.n.f的对象访问实例字段q1.b0 p1.l0.n.e.b(声明'okhttp3.internal.huc.OkHttpURLConnection'出现在/data/app/…=/base.apk:classes3.dex中)我们绝对不能降级到3.13.1以获得官方的
内部.huc.OkHttpURLConnection
至少需要3.14.7才能与Android R兼容(根据改装变更日志)。我在这里发布了一个解决方法: