简体   繁体   English

如何在Android应用程序中使用rt.jar中的类?

[英]How to use classes from rt.jar in an android application?

I am building an android application that references an external library. 我正在构建一个引用外部库的android应用程序。 The problem is that library uses java.beans.PropertyDescriptor and this causes Dalvik exception at runtime. 问题在于该库使用java.beans.PropertyDescriptor,这在运行时导致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. 我在另一个论坛上发现可以操纵字节码来加载Dalvik未知的类。

Any suggestions ? 有什么建议么 ?

Thanks 谢谢

How can I solve this problem ? 我怎么解决这个问题 ?

Get the source code to the external library and rewrite it to avoid java.beans.PropertyDescriptor . 将源代码获取到外部库,然后重写它以避免使用java.beans.PropertyDescriptor

For example, you could: 例如,您可以:

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

Bear in mind that there may be many other problems with this library, which apparently was not written with Android in mind. 请记住,此库可能还有许多其他问题,显然这些问题并不是在考虑Android的情况下编写的。

I found on another forum that it was possible to manipulate bytecode to load classes that are not known from Dalvik. 我在另一个论坛上发现可以操纵字节码来加载Dalvik未知的类。

Since there is no java.beans.PropertyDescriptor on Android devices, this will not help you. 由于Android设备上没有java.beans.PropertyDescriptor ,因此这对您没有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM