从 API23 中移除 Apache HTTP 客户端,这会对 Volley 产生影响吗? [英] Apache HTTP Client Removal from API23, will that have an effect on Volley?

查看:26
本文介绍了从 API23 中移除 Apache HTTP 客户端,这会对 Volley 产生影响吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如我们所知,Apache HTTP ClientAPI 23

中被删除

compileSdkVersion 23

我有两个问题:

  1. 当然,使用 Volley 的 API23 项目仍然可以成功运行.但是,我不明白他们如何在运行时使用 Apache 的库,是吗?在 API22 或更低版本中查找?
  2. 另外,我想知道在不久的将来,Volley 会不会升级,所以不再使用 Apache 的库?如果没有,当 Apache 的库被完全删除且不受支持时,我当前的项目将来是否仍然有效?

也许我的英文不太清楚,但希望你能理解我的问题.

任何解释将不胜感激.

更新:

根据@random 的评论,我使用 Google 的官方 Volley 库创建了一个新的 API23 项目(我的意思是 Google 建议的 git clone https://android.googlesource.com/platform/frameworks/volley此处),而不是使用 compile 'com.mcxiaoke.volley:library:1.0.17'build.gradle 文件中.是的,在构建项目时由于缺少 Apache 库而出错.必须按照文档将 useLibrary 'org.apache.http.legacy' 添加到 build.gradle 文件中.

<小时>

第二次更新:

我刚刚定制了 Google 的 volley(作为我项目中的一个模块)删除了 Apache 库.请转到我的GitHub示例项目供您参考.但是,请注意,它尚未针对所有情况进行全面测试,我仅测试了 02 个简单情况:GETPOST 请求,我的网络服务为 ASP.NET Web API.

解决方案

Android M 中的 Volley 库似乎很混乱.一个错误已经提交并被谷歌承认.

https://code.google.com/p/android-developer-preview/issues/detail?id=3013

您应该加注星标并跟踪它以获取任何进一步的更新

更新

关于您的第一个问题,您不会因为缺少 apache 文件而收到错误消息,因为您使用的库仍然是使用 API 22 编译的

ANDROID_BUILD_TARGET_SDK_VERSION=22ANDROID_BUILD_TOOLS_VERSION=22.0.1ANDROID_BUILD_SDK_VERSION=22

https://github.com/mcxiaoke/android-volley/blob/master/gradle.properties

另请从库中查看此未解决的问题您可以根据它添加遗留库

android {compileSdkVersion 23构建工具版本23.0.0"useLibrary 'org.apache.http.legacy'...}

As we have known that Apache HTTP Client removed in API 23

Apache HTTP Client Removal

However, Volley library currently still uses Apache's library such as

import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.StatusLine;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.impl.cookie.DateUtils;

And I have tested 2 projects: one with compileSdkVersion 22, the other with compileSdkVersion 23, got 2 screenshots:

compileSdkVersion 22

compileSdkVersion 23

I have 2 questions:

  1. Of course, API23 projects using Volley still work successfully. However, I don't understand how they use the Apache's library at runtime, do they find in API22 or lower instead?
  2. Moreover, I wonder if in the near future, will Volley be upgraded so that no longer uses Apache's library? If not, will my current projects still work in the future when Apache's library completely removed and not supported?

Perhaps my English is not so clear, however, hope that you understand my question.

Any explanation will be appreciated.

UPDATE:

From @random's comments, I created a new API23 project using Google's official Volley library (I mean by git clone https://android.googlesource.com/platform/frameworks/volley as Google suggested here), instead of using compile 'com.mcxiaoke.volley:library:1.0.17' in build.gradle file. Yes, got errors with lack of Apache library when building project. Must add useLibrary 'org.apache.http.legacy' into build.gradle file as documented.


2nd UPDATE:

I have just customized Google's volley (as a module in my project) removing Apache library. Please go to my GitHub sample project for your reference. However, please note that it has not been fully tested for all cases, and I have tested only 02 simple cases: GET and POST requests with my web service that is ASP.NET Web API.

解决方案

It seems there has been quite a mess with the Volley library in Android M. A bug has already been filed for it and acknowledged by google.

https://code.google.com/p/android-developer-preview/issues/detail?id=3013

You should star and track it for any further updates

UPDATE

Regarding your first question, you don't get an error for missing apache files because the library that you're using is still compiled using API 22

ANDROID_BUILD_TARGET_SDK_VERSION=22
ANDROID_BUILD_TOOLS_VERSION=22.0.1
ANDROID_BUILD_SDK_VERSION=22

https://github.com/mcxiaoke/android-volley/blob/master/gradle.properties

Also check this open issue from the library according to which you can add legacy library

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    useLibrary 'org.apache.http.legacy'
    ...
}

这篇关于从 API23 中移除 Apache HTTP 客户端,这会对 Volley 产生影响吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆