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

a 夏天 提交于 2021-01-28 10:37:01

问题


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.

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.

Any suggestions ?

Thanks


回答1:


How can I solve this problem ?

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

For example, you could:

  • 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

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

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

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



来源:https://stackoverflow.com/questions/14440194/how-to-use-classes-from-rt-jar-in-an-android-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!