Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
282 views
in Technique[技术] by (71.8m points)

android - Apache HTTP Client Removal from API23, will that have an effect on Volley?

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

enter image description here

compileSdkVersion 23

enter image description here

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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'
    ...
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...