无法解析 Apache HTTP 库以发送请求和接收响应
unable to resolve Apache HTTP library to send Request and Receive Response
我正在尝试使用 Apache HTTP 库上传图片,但我会遇到这种错误。
Caused by: java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/message/BasicHeaderValueFormatter; in class Lorg/apache/http/message/BasicHeaderValueFormatter; or its superclasses (declaration of 'org.apache.http.message.BasicHeaderValueFormatter' appears in /system/framework/ext.jar)
在 org.apache.http.entity.ContentType.toString(ContentType.java:153)
它会给出库错误并使我的应用程序崩溃。无法找到有关此问题的解决方案
here is my logcat.
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #5
Process: com.technotechindia.talknshop, PID: 9660
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask.done(AsyncTask.java:304)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/message/BasicHeaderValueFormatter; in class Lorg/apache/http/message/BasicHeaderValueFormatter; or its superclasses (declaration of 'org.apache.http.message.BasicHeaderValueFormatter' appears in /system/framework/ext.jar)
at org.apache.http.entity.ContentType.toString(ContentType.java:153)
at org.apache.http.entity.mime.MultipartFormEntity.<init>(MultipartFormEntity.java:53)
at org.apache.http.entity.mime.MultipartEntityBuilder.buildEntity(MultipartEntityBuilder.java:236)
at org.apache.http.entity.mime.MultipartEntity.getEntity(MultipartEntity.java:119)
at org.apache.http.entity.mime.MultipartEntity.isChunked(MultipartEntity.java:138)
at org.apache.http.protocol.RequestContent.process(RequestContent.java:84)
at org.apache.http.protocol.BasicHttpProcessor.process(BasicHttpProcessor.java:295)
at org.apache.http.protocol.HttpRequestExecutor.preProcess(HttpRequestExecutor.java:165)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:427)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:580)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:503)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:481)
at com.technotechindia.talknshop.AddStoreToLocation$UploadImages.doInBackground(AddStoreToLocation.java:454)
at com.technotechindia.talknshop.AddStoreToLocation$UploadImages.doInBackground(AddStoreToLocation.java:372)
at android.os.AsyncTask.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
所以每当我要请求服务器给我这种错误时
遗憾的是,HttpCore 的库存版本无法在 Android 中使用。请使用 Apache HttpClient Android 端口,其中还包括必要的 HttpCore 类
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
为我工作
compile 'org.apache.httpcomponents:httpmime:4.3.6'
compile 'org.apache.httpcomponents:httpcore:4.4.5'
我正在尝试使用 Apache HTTP 库上传图片,但我会遇到这种错误。
Caused by: java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/message/BasicHeaderValueFormatter; in class Lorg/apache/http/message/BasicHeaderValueFormatter; or its superclasses (declaration of 'org.apache.http.message.BasicHeaderValueFormatter' appears in /system/framework/ext.jar)
在 org.apache.http.entity.ContentType.toString(ContentType.java:153) 它会给出库错误并使我的应用程序崩溃。无法找到有关此问题的解决方案
here is my logcat.
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #5
Process: com.technotechindia.talknshop, PID: 9660
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask.done(AsyncTask.java:304)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/message/BasicHeaderValueFormatter; in class Lorg/apache/http/message/BasicHeaderValueFormatter; or its superclasses (declaration of 'org.apache.http.message.BasicHeaderValueFormatter' appears in /system/framework/ext.jar)
at org.apache.http.entity.ContentType.toString(ContentType.java:153)
at org.apache.http.entity.mime.MultipartFormEntity.<init>(MultipartFormEntity.java:53)
at org.apache.http.entity.mime.MultipartEntityBuilder.buildEntity(MultipartEntityBuilder.java:236)
at org.apache.http.entity.mime.MultipartEntity.getEntity(MultipartEntity.java:119)
at org.apache.http.entity.mime.MultipartEntity.isChunked(MultipartEntity.java:138)
at org.apache.http.protocol.RequestContent.process(RequestContent.java:84)
at org.apache.http.protocol.BasicHttpProcessor.process(BasicHttpProcessor.java:295)
at org.apache.http.protocol.HttpRequestExecutor.preProcess(HttpRequestExecutor.java:165)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:427)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:580)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:503)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:481)
at com.technotechindia.talknshop.AddStoreToLocation$UploadImages.doInBackground(AddStoreToLocation.java:454)
at com.technotechindia.talknshop.AddStoreToLocation$UploadImages.doInBackground(AddStoreToLocation.java:372)
at android.os.AsyncTask.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
所以每当我要请求服务器给我这种错误时
遗憾的是,HttpCore 的库存版本无法在 Android 中使用。请使用 Apache HttpClient Android 端口,其中还包括必要的 HttpCore 类
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
为我工作
compile 'org.apache.httpcomponents:httpmime:4.3.6'
compile 'org.apache.httpcomponents:httpcore:4.4.5'