如何在Android中使用Android中没有的包编译的jar库
我需要导入几个在 java 的完整实现下编译的 jars。我知道Android并没有使用java提供的所有包。我的问题是:是否可以在不产生错误的情况下导入它们?有没有可以将jar转换为android jar的工具?如果是的话,能否提供一些例子。非常感谢任何帮助。
I need to import a couple of jars that where compiled under the full implementation of java. I know that Android doesn't use all the packages that java has to offer. My question is: Is it possible to import them without creating errors? Is there a tool that can convert jars to android jars? if so, can some examples be provided. Any help is much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 JAR 引用 Android 没有的类,则不会。
不存在“android jars”这样的东西。
如果您有相关 JAR 的源代码,在修改该源代码和修改 Apache Harmony 中缺少的类的副本之间,您也许能够让东西正常工作。但是,您不能只将
java.*
或javax.*
类放入项目中 - 您必须将它们重构到新包中。此外,根据缺少的类,这可能需要数千个开发人员几个月才能完成(例如,使用 2D Canvas API 重新实现 Swing)。If the JARs refer to classes that Android does not have, no.
There is no such thing as "android jars".
If you have the source code to the JARs in question, between modifying that source code and modifying copies of the missing classes from Apache Harmony, you may be able to get stuff working. However, you cannot just put
java.*
orjavax.*
classes in your project -- you will have to refactor them into new packages. Also, depending on what classes are missing, this may take thousands of developer-months to accomplish (e.g., reimplementing Swing using 2D Canvas APIs).