更改或升级内置的org.json库是可能的,还是个好主意? [英] changing or upgrading built-in org.json libraries, is possible and a good idea?

查看:157
本文介绍了更改或升级内置的org.json库是可能的,还是个好主意?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在很大程度上取决于JSON库org.json.*.该软件包内置于Android标准库中,这是我不知道的,因为我也将其包含在源代码树中.

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.

我需要使用内置软件包不支持的函数(JSONArray.remove),而该函数位于org.json的源分发罐中(我包含在我的项目中).因此,发生的事情是,所有内容都会编译并生成.全部,但在运行时出现 java.lang.NoSuchMethodError:org.json.JSONArray.remove .

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.

我的问题是,如何告诉eclipse或Android使用源树中的org.json.*而不是其内置版本?

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?

还有一个子问题:这是个好主意吗?内置的JSON包可能相对于官方源代码发行版具有本机级别的改进吗?

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?

推荐答案

我的问题是,如何告诉eclipse或Android使用源树中的org.json.*而不是其内置版本?

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.

欢迎您使用 jarjar 或类似工具移动您将org.json类的副本复制到新程序包中.或者,找到一个更好的JSON库-那里有很多.

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.

这篇关于更改或升级内置的org.json库是可能的,还是个好主意?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆