Search code examples
javaandroiddalvik

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


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


Solution

  • 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.