Android java.lang.NoSuchMethodError:没有虚方法 [英] Android java.lang.NoSuchMethodError: No virtual method
问题描述
我想发送一个帖子请求,以便通过Google表单将数据发送到我的工作表
I would like to send a post request to send data to my worksheet by Google Form
I使用Android Studio,在我的android项目中,当我尝试执行 DefaultHttpClient
对象时出错:
I use Android Studio, in my android project I have an error when I try to execute DefaultHttpClient
object I get :
---------崩溃开始
10-26 16:19:08.749 21824-22874 / mypackage E / AndroidRuntime:FATAL EXCEPTION:Thread-1553
进程:mypackage,PID:21824
java.lang.NoSuchMethodError:没有虚方法执行(Lorg / apache / http / client / methods / HttpUriRequest; Lorg / apache / http / protocol / HttpContext;)Lorg / apache / http /客户端/方法/ CloseableHttpResponse;在类Lorg / apache / http / impl / client / DefaultHttpClient中;或其超类('org.apache.http.impl.client.DefaultHttpClient'的声明出现在/system/framework/org.apache.http.legacy.boot.jar)
--------- beginning of crash 10-26 16:19:08.749 21824-22874/mypackage E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-1553 Process: mypackage, PID: 21824 java.lang.NoSuchMethodError: No virtual method execute(Lorg/apache/http/client/methods/HttpUriRequest;Lorg/apache/http/protocol/HttpContext;)Lorg/apache/http/client/methods/CloseableHttpResponse; in class Lorg/apache/http/impl/client/DefaultHttpClient; or its super classes (declaration of 'org.apache.http.impl.client.DefaultHttpClient' appears in /system/framework/org.apache.http.legacy.boot.jar)
错误报告给该行: response = httpClient.execute(httpPost,localContext);
我使用httpclient-4.5.1.jar库
minSDK:API 15:Android 4.0.3(IceCreamSandwich)
我不知道如何解决这个问题!请帮帮我!
I don't know how to fix this! Please Help Me!
推荐答案
在build.gradle android部分输入此代码
useLibrary' org.apache.http.legacy'
in build.gradle android section put this code
useLibrary 'org.apache.http.legacy'
这篇关于Android java.lang.NoSuchMethodError:没有虚方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!