Android java.lang.NoSuchMethodError: 没有虚方法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33349683/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 21:32:53  来源:igfitidea点击:

Android java.lang.NoSuchMethodError: No virtual method

javaandroidhttpclientgoogle-formhttp-request

提问by mc_marad

I would like to send a post request to send data to my worksheet by Google Form

我想发送一个 post 请求,通过 Google 表单将数据发送到我的工作表

I use Android Studio, in my android project I have an error when I try to execute DefaultHttpClientobject I get :

我使用 Android Studio,在我的 android 项目中,当我尝试执行DefaultHttpClient我得到的对象时出现错误:

--------- 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)

--------- 崩溃开始 10-26 16:19:08.749 21824-22874/mypackage E/AndroidRuntime: FATAL EXCEPTION: Thread-1553 Process: mypackage, PID: 21824 java.lang.NoSuchMethodError: No virtual方法执行(Lorg/apache/http/client/methods/HttpUriRequest;Lorg/apache/http/protocol/HttpContext;)Lorg/apache/http/client/methods/CloseableHttpResponse; 在类 Lorg/apache/http/impl/client/DefaultHttpClient 中;或其超类('org.apache.http.impl.client.DefaultHttpClient' 的声明出现在 /system/framework/org.apache.http.legacy.boot.jar 中)

the error is reported to the line: response = httpClient.execute(httpPost,localContext);

错误报告给该行: response = httpClient.execute(httpPost,localContext);

I use httpclient-4.5.1.jar library

我使用 httpclient-4.5.1.jar 库

minSDK: API 15: Android 4.0.3 (IceCreamSandwich)

minSDK: API 15: Android 4.0.3 (IceCreamSandwich)

I don't know how to fix this! Please Help Me!

我不知道如何解决这个问题!请帮我!

回答by Milon

in build.gradle android section put this code
useLibrary 'org.apache.http.legacy'

在 build.gradle android 部分把这个代码
useLibrary 'org.apache.http.legacy'