Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top