I've an AsyncTask
with below code
private void getJSON(final String urlWebService) {
class GetJSON extends AsyncTask<Void, Void, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected void onPostExecute(String s) {
super.onPostExcute();
}
@Override
protected String doInBackground(Void... voids) {
try {
URL url = new URL(urlWebService);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
StringBuilder sb = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream()));
String json;
while ((json = bufferedReader.readLine()) != null) {
sb.append(json);
}
return sb.toString().trim();
} catch (Exception e) {
Log.i("BG Exception", e.getMessage());
return "";
}
}
}
new GetJSON().execute();
But, unfortunately it returns error
like below
java.lang.VerifyError: Verifier rejected class net.simplifiedlearning.androidjsonparsing.MainActivity$100000000$GetJSON due to bad method void net.simplifiedlearning.androidjsonparsing.MainActivity$100000000$GetJSON.<init>(net.simplifiedlearning.androidjsonparsing.MainActivity, java.lang.String) (declaration of 'net.simplifiedlearning.androidjsonparsing.MainActivity$100000000$GetJSON' appears in /data/app/net.simplifiedlearning.androidjsonparsing-1/base.apk)
05-25 11:04:26.146 29104 29104 E AndroidRuntime at net.simplifiedlearning.androidjsonparsing.MainActivity.getJSON(MainActivity.java:76)
I've found it's solution. The error says
Verifier rejected AsyncTask due to bad void
The AsyncTask
is in a void
method. And that was doing the problem. Though, I don't know why?
When I've removed the getJSON()
void which was surrounding AsyncTask
everything became fine and worked expectedly.