如何在Android应用程序中使用rt.jar中的类? [英] How to use classes from rt.jar in an android application?

查看:87
本文介绍了如何在Android应用程序中使用rt.jar中的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个引用外部库的android应用程序.问题在于该库使用java.beans.PropertyDescriptor,这会在运行时导致Dalvik异常.

I am building an android application that references an external library. The problem is that library uses java.beans.PropertyDescriptor and this causes Dalvik exception at runtime.

我该如何解决这个问题?我在另一个论坛上发现可以操纵字节码来加载Dalvik未知的类.

How can I solve this problem ? I found on another forum that it was possible to manipulate bytecode to load classes that are not known from Dalvik.

有什么建议吗?

谢谢

推荐答案

我该如何解决这个问题?

How can I solve this problem ?

将源代码获取到外部库中并重写它以避免 java.beans.PropertyDescriptor .

Get the source code to the external library and rewrite it to avoid java.beans.PropertyDescriptor.

例如,您可以:

  • 从诸如Apache Harmony之类的地方查找到实现 java.beans.PropertyDescriptor 的源副本.
  • java.beans.PropertyDescriptor 重构为 some.other.package.PropertyDescriptor
  • some.other.package.PropertyDescriptor 添加到您的项目中
  • 修改外部库的源代码以使用 some.other.package.PropertyDescriptor
  • Find a copy of the source to an implementation java.beans.PropertyDescriptor from someplace like Apache Harmony
  • Refactor java.beans.PropertyDescriptor to some.other.package.PropertyDescriptor
  • Add some.other.package.PropertyDescriptor to your project
  • Modify the source code of the external library to use some.other.package.PropertyDescriptor

请记住,此库可能还有很多其他问题,显然不是在考虑Android的情况下编写的.

Bear in mind that there may be many other problems with this library, which apparently was not written with Android in mind.

我在另一个论坛上发现,可以操纵字节码来加载Dalvik未知的类.

I found on another forum that it was possible to manipulate bytecode to load classes that are not known from Dalvik.

由于Android设备上没有 java.beans.PropertyDescriptor ,因此这对您没有帮助.

Since there is no java.beans.PropertyDescriptor on Android devices, this will not help you.

这篇关于如何在Android应用程序中使用rt.jar中的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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