Android API and java.beans package

Android API mirrors the official JDK so closely that it’s easy to forget it’s not the official JDK. I was reminded of today when I started testing my project on Android. When I ran the project, I got a “java.lang.VerifyError” which didn’t make much sense at first but after further debugging, I realized that my project needed some classes from JDK’s java.beans package, namely:

  • java.beans.BeanInfo
  • java.beans.IntrospectionException
  • java.beans.Introspector
  • java.beans.PropertyDescriptor

These and many other classes in java.beans package are missing from the Android API. I see a few solutions:

  1. Get my project not depend on any java.beans classes. This is problematic as the code depends on the java.beans package heavily.
  2. Look into Apache Harmony. I’ve read in some forum that they have beans.jar that could help but couldn’t get my hands on it yet and not sure if it’ll work with Android’s Dalvik without too much pain.
  3. Copy JDK’s source for the java.beans classes that I need into my project and compile them with Dalvik. I’m not sure if this is permitted or whether it’d work but it’s worth a try, I suppose.

Any other solutions?

4 thoughts on “Android API and java.beans package

Leave a comment