changing or upgrading built-in org.json libraries, is possible and a good idea?

久未见 提交于 2020-01-15 07:22:31

问题


My application depends a lot on the JSON library org.json.*. This package is built-in into Android standard libraries, something I didn't know because I also included it in my source tree.

I need to use a function (JSONArray.remove) that is not supported on the built-in package, while it is in the source distribution jar from org.json (that I include in my project). So what happens is, everything compiles & all, but I get java.lang.NoSuchMethodError: org.json.JSONArray.remove at runtime.

My question is, how can I tell eclipse or Android to use the org.json.* from my source tree instead of its built-in version?

And a sub-question: Is it a good idea at all? May the built-in JSON package have native-level improvements or something like that vs. the official source code distribution?


回答1:


My question is, how can I tell eclipse or Android to use the org.json.* from my source tree instead of its built-in version?

You can't. You do not control the runtime classpath, and the firmware always wins.

You are welcome to use jarjar or a similar tool to move your copy of the org.json classes into a new package. Or, find a better JSON library -- there's lots of them out there.



来源:https://stackoverflow.com/questions/20389105/changing-or-upgrading-built-in-org-json-libraries-is-possible-and-a-good-idea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!