Android 4.4.2旧版org.apache.http.client.HttpClient
但我想使用我通过jar添加的新版org.apache.http.client.HttpClient
。
如何强制Android从jar而不是框架本身使用org.apache.http.client.HttpClient
。
我正在使用此
创建客户端this.mRequestQueue = Volley.newRequestQueue(
mCtx.getApplicationContext(), new HttpClientStack(HttpClientBuilder.create().build()));
并且因为它从框架(即旧版本)导入org.apache.http.client.HttpClient
,所以它会引发异常
04-23 18:15:42.252: E/AndroidRuntime(24527): FATAL EXCEPTION: main
04-23 18:15:42.252: E/AndroidRuntime(24527): Process: com.az, PID: 24527
04-23 18:15:42.252: E/AndroidRuntime(24527): java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/message/BasicLineFormatter; in class Lorg/apache/http/message/BasicLineFormatter; or its superclasses (declaration of 'org.apache.http.message.BasicLineFormatter' appears in /system/framework/ext.jar)
04-23 18:15:42.252: E/AndroidRuntime(24527): at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:52)
04-23 18:15:42.252: E/AndroidRuntime(24527): at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:56)
04-23 18:15:42.252: E/AndroidRuntime(24527): at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<clinit>(DefaultHttpRequestWriterFactory.java:46)
04-23 18:15:42.252: E/AndroidRuntime(24527): at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<init>(ManagedHttpClientConnectionFactory.java:72)
04-23 18:15:42.252: E/AndroidRuntime(24527): at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<init>(ManagedHttpClientConnectionFactory.java:84)
04-23 18:15:42.252: E/AndroidRuntime(24527): at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<clinit>(ManagedHttpClientConnectionFactory.java:59)
04-23 18:15:42.252: E/AndroidRuntime(24527): at org.apache.http.impl.conn.PoolingHttpClientConnectionManager$InternalConnectionFactory.<init>(PoolingHttpClientConnectionManager.java:494)
04-23 18:15:42.252: E/AndroidRuntime(24527): at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:149)
04-23 18:15:42.252: E/AndroidRuntime(24527): at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:138)
04-23 18:15:42.252: E/AndroidRuntime(24527): at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:114)
04-23 18:15:42.252: E/AndroidRuntime(24527): at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:726)
04-23 18:15:42.252: E/AndroidRuntime(24527): at com.beusoft.app.VolleySingleton.getRequestQueue(VolleySingleton.java:39)
04-23 18:15:42.252: E/AndroidRuntime(24527): at com.beusoft.app.VolleySingleton.<init>(VolleySingleton.java:27)
04-23 18:15:42.252: E/AndroidRuntime(24527): at com.beusoft.app.VolleySingleton.getInstance(VolleySingleton.java:32)
04-23 18:15:42.252: E/AndroidRuntime(24527): at com.beusoft.app.AppContext.onCreate(AppContext.java:101)
04-23 18:15:42.252: E/AndroidRuntime(24527): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012)
04-23 18:15:42.252: E/AndroidRuntime(24527): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4553)
04-23 18:15:42.252: E/AndroidRuntime(24527): at android.app.ActivityThread.access$1500(ActivityThread.java:151)
04-23 18:15:42.252: E/AndroidRuntime(24527): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
04-23 18:15:42.252: E/AndroidRuntime(24527): at android.os.Handler.dispatchMessage(Handler.java:102)
04-23 18:15:42.252: E/AndroidRuntime(24527): at android.os.Looper.loop(Looper.java:135)
04-23 18:15:42.252: E/AndroidRuntime(24527): at android.app.ActivityThread.main(ActivityThread.java:5254)
04-23 18:15:42.252: E/AndroidRuntime(24527): at java.lang.reflect.Method.invoke(Native Method)
04-23 18:15:42.252: E/AndroidRuntime(24527): at java.lang.reflect.Method.invoke(Method.java:372)
04-23 18:15:42.252: E/AndroidRuntime(24527): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
04-23 18:15:42.252: E/AndroidRuntime(24527): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
如何强制Android从库而不是框架版本中使用org.apache.http.client.HttpClient
。
答案 0 :(得分:1)
你不能。
您基本上有两种选择:
org.apache.http - &gt; thank.you.google.org.apache.http