问题
I would like to send a post request to send data to my worksheet by Google Form
I use Android Studio, in my android project I have an error when I try to execute DefaultHttpClient
object I get :
--------- 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)
the error is reported to the line: response = httpClient.execute(httpPost,localContext);
I use httpclient-4.5.1.jar library
minSDK: API 15: Android 4.0.3 (IceCreamSandwich)
I don't know how to fix this! Please Help Me!
回答1:
in build.gradle android section put this code
useLibrary 'org.apache.http.legacy'
来源:https://stackoverflow.com/questions/33349683/android-java-lang-nosuchmethoderror-no-virtual-method