类型不匹配:无法从org.apache.http.HttpResponse转换

use*_*367 0 java android httprequest

我正在尝试通过发出HTTP请求更新Android中的MySQL数据,但它给了我一个错误

"类型不匹配:无法从org.apache.http.HttpResponse转换为com.google.api.client.http.HttpResponse"

在这行代码"httpClient.execute(httpPost)"

HttpResponse response = httpClient.execute(httpPost);
Run Code Online (Sandbox Code Playgroud)

它通过添加org.apache.http来提供快速修复的选项

org.apache.http.HttpResponse response = httpClient.execute(httpPost);
Run Code Online (Sandbox Code Playgroud)

有人能告诉我这里我做错了什么吗?非常感谢!

protected String doInBackground(String... params) {

    HttpClient httpClient = new DefaultHttpClient();
    HttpPost httpPost = new HttpPost("http://---.com/---/approve_request.php");

    List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>();
    nameValuePair.add(new BasicNameValuePair("status", "Approved"));

    try {
          httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
        } catch (UnsupportedEncodingException e) {              
           e.printStackTrace();
        }

           try {
              org.apache.http.HttpResponse response = httpClient.execute(httpPost);  
              Log.d("Http Response:", response.toString());

         } catch (ClientProtocolException e) {             
              e.printStackTrace();

         } catch (IOException e) {              
              e.printStackTrace();

         }

    return null;
    }
Run Code Online (Sandbox Code Playgroud)

kos*_*osa 5

您的代码中有错误的import语句.

转到课堂顶部并寻找

import com.google.api.client.http.HttpResponse

用它替换它

import org.apache.http.HttpResponse
Run Code Online (Sandbox Code Playgroud)