duanjian5059 2016-04-04 02:27
浏览 269

Android登录注册系统,PHP,MySQL错误'java.lang.NoSuchMethodError:org.apache.http.impl.client.DefaultHttpClient.execute'

I have develop Android Login Registration System with PHP, MySQL. This is Simple questions but confuses me. i got many error as below log.

Caused by: java.lang.NoSuchMethodError: org.apache.http.impl.client.DefaultHttpClient.execute at com.chinatown.wangjian.chinatown_loginv10.Library.JSONParser.getJSONFromUrl(JSONParser.java:45) at com.chinatown.wangjian.chinatown_loginv10.Library.UserFunctions.loginUser(UserFunctions.java:42) at com.chinatown.wangjian.chinatown_loginv10.Login$ProcessLogin.doInBackground(Login.java:194) at com.chinatown.wangjian.chinatown_loginv10.Login$ProcessLogin.doInBackground(Login.java:170) at com.chinatown.wangjian.chinatown_loginv10.Register$ProcessRegister.onPreExecute(Register.java:197) at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586) at android.os.AsyncTask.execute(AsyncTask.java:534) at com.chinatown.wangjian.chinatown_loginv10.Register$NetCheck.onPostExecute(Register.java:167) at com.chinatown.wangjian.chinatown_loginv10.Register$NetCheck.onPostExecute(Register.java:119) >at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586) at android.os.AsyncTask.execute(AsyncTask.java:534) at com.chinatown.wangjian.chinatown_loginv10.Login$NetCheck.onPostExecute(Login.java:159) at com.chinatown.wangjian.chinatown_loginv10.Login$NetCheck.onPostExecute(Login.java:110)

there are part of my java code:

JSONParser.java

        HttpResponse httpResponse = httpClient.execute(httpPost);
        HttpEntity httpEntity = httpResponse.getEntity();
        is = httpEntity.getContent();

UserFunctions

public JSONObject registerUser(String mobile, String email, String uname, String password){
    // Building Parameters
    List params = new ArrayList();
    params.add(new BasicNameValuePair("tag", register_tag));
    params.add(new BasicNameValuePair("mobile", mobile));
    params.add(new BasicNameValuePair("email", email));
    params.add(new BasicNameValuePair("uname", uname));
    params.add(new BasicNameValuePair("password", password));
    JSONObject json = jsonParser.getJSONFromUrl(registerURL,params);
    return json;
}

Register.java

  private class ProcessRegister extends AsyncTask<String, String, JSONObject> {
    private ProgressDialog pDialog;

    String email,password,mobile,uname;

    @Override
    protected void onPreExecute() {
        // TODO Auto-generated method stub
        super.onPreExecute();
        inputUsername = (EditText) findViewById(R.id.uname);
        inputPassword = (EditText) findViewById(R.id.password);
        mobile = inputMobile.getText().toString();
        email = inputEmail.getText().toString();
        uname= inputUsername.getText().toString();
        password = inputPassword.getText().toString();
        pDialog = new ProgressDialog(Register.this);
        pDialog.setTitle("正在链接服务器");
        pDialog.setMessage("注册中 ...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(true);
        pDialog.show();
    }

 protected JSONObject doInBackground(String... args) {


        UserFunctions userFunction = new UserFunctions();
        JSONObject json = userFunction.registerUser(mobile, email, uname, password);

        return json;


    }

 private class NetCheck extends AsyncTask<String,String,Boolean>
{
    private ProgressDialog nDialog;

    @Override
    protected void onPreExecute(){
        super.onPreExecute();
        nDialog = new ProgressDialog(Register.this);
        nDialog.setMessage("加载中..");
        nDialog.setTitle("正在检查网络");
        nDialog.setIndeterminate(false);
        nDialog.setCancelable(true);
        nDialog.show();
    }

I have refer the website try to fixed https://community.oracle.com/thread/2279492?start=0 and upgrade the httpcore-4.1.jar to latest version as below libs folder image. but it is not work for my project. I'm a newbie at this stuff so any help will be appreciated. Thanks in Advance!

libs folder

  • 写回答

1条回答 默认 最新

  • doudanglang5826 2016-04-04 02:49
    关注

    The way you trying to communicate is obsolete. I mean many of class have been depricated, such as DefaultHttpClient, BasicNameValuePair,HttpResponse etc. Use HTTPUrlConnection for better performance.

    评论

报告相同问题?

悬赏问题

  • ¥15 全志H618ROM新增分区
  • ¥20 jupyter保存图像功能的实现
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况