So I am attempting to use Apache Commons in Android, and I am getting a VerifyError. I have the httpclient-4.5.1 library imported into my External Jars in my build path. When I run it, I am getting a VerifyError:
This is my code; it crashes on the first line of code:
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
try {
HttpPost url= new HttpPost("http://192.168.10.2:8080/iNSIGHTJSON");
StringEntity parameter = new StringEntity("{ \"getNewWifi\" : [ 0 ] }");
url.addHeader("content-type", "a" + "pplicati" + "on/json");
url.setEntity(parameter);
httpClient.execute(url);
ResponseHandler<String> responseHandler=new BasicResponseHandler();
String responseBody = httpClient.execute(url, responseHandler);
JSONObject response=new JSONObject(responseBody);
Log.d("json object", responseBody);
RunWifiAnalysis.this.getActivity().runOnUiThread(new Runnable() {
public void run() {
((SmartCpeAtt) getActivity()).switchTabSet(R.id.wifi0, 1);
}
});
// handle response here...
} catch (Exception ex) {
// handle exception here
}
Is this just an Android issue, or am I doing something wrong? The code works on a blank Java project, but does for Android. Is the library not compatible? If so, what is something similar I can use that is compatible and does what I want it to?