在Java工程中尝试使用Android库中的org.json.JSONObject类,在执行时出现“Stub!”错误,
执行代码
// Load the requested page converted to a string into a JSONObject.
JSONObject jsonResponse = new JSONObject(sb.toString());
控制台显示错误:
Exception in thread "main" java.lang.RuntimeException: Stub!
at org.json.JSONObject.<init>(JSONObject.java:8)
如另一篇Android工程中无法执行java的main函数相似,Android工程和Java工程还有一定的差异,不能混用他们的库,和函数入口方法。
将上面的代码,移植到在Android工程可以正确执行!