Android java.lang.NoSuchMethodError: No virtual method

て烟熏妆下的殇ゞ 提交于 2019-12-20 07:43:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!