为了账号安全,请及时绑定邮箱和手机立即绑定

来自androidhive教程的JSONParser,DefaultHttpClient

来自androidhive教程的JSONParser,DefaultHttpClient

波斯汪 2019-11-20 12:50:08
我正在遵循本教程,并遇到此错误:Caused by: java.lang.NoSuchMethodError: No virtual method execute(Lorg/apache/http/client/methods/HttpUriRequest;)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/ext.jar)                at info.androidhive.materialtabs.adpater.JSONParser.makeHttpRequest(JSONParser.java:52)                at info.androidhive.materialtabs.UserFunctions.loginUser(UserFunctions.java:37)                at info.androidhive.materialtabs.activity.MainActivity$Login.doInBackground(MainActivity.java:551)                at info.androidhive.materialtabs.activity.MainActivity$Login.doInBackground(MainActivity.java:519)这是我正在使用的JSONParser类:public class JSONParser {     static InputStream is = null;        static JSONObject jObj = null;        static String json = "";        // constructor        public JSONParser() {        }        // function get json from url        // by making HTTP POST or GET method        public JSONObject makeHttpRequest(String url, String method,                List<NameValuePair> params) {            // Making HTTP request            try {                // check for request method                if(method == "POST"){                    // request method is POST                    // defaultHttpClient                    DefaultHttpClient httpClient = new DefaultHttpClient();                    HttpPost httpPost = new HttpPost(url);                    httpPost.setEntity(new UrlEncodedFormEntity(params));                    HttpResponse httpResponse = httpClient.execute(httpPost);                    HttpEntity httpEntity = httpResponse.getEntity();                    is = httpEntity.getContent();                }
查看完整描述

2 回答

?
慕无忌1623718

TA贡献1744条经验 获得超4个赞

错误:(74,37)错误:类JSONParser中的方法makeHttpRequest无法应用于给定类型;必需:String,String,HashMap <String,String>找到:String,String,List <NameValuePair>原因:实际参数List <NameValuePair>不能通过方法调用转换转换为HashMap <String,String>

查看完整回答
反对 回复 2019-11-20
  • 2 回答
  • 0 关注
  • 585 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信