Android - java.lang.RuntimeException: Stub exception while parsing a string in JSONObject

I get an exception java.lang.RuntimeException: Stub!when I try to parse Stringon org.json.JSONObject. My version of Android is 19 .

Here is my analysis String:

{
    "url": "http://www.google.com",
    "cookie": "012121",
    "filename": "Google"
}


JSONObject jsonObject = new JSONObject(str); // getting exception at this line
String url = jsonObject.getString("url");
+3
source share
1 answer

Probably because you are using the json version with Android support and you are not running it on an Android device or emulator.

Depending on your actual need, you can:

  • run it on the device or emulator
  • use a different json library instead of the built-in in android
  • use roboelectric to run your test (if it's a test) without an emulator: http://robolectric.org/
+6

All Articles