Looking up .class-files via Classloader.getResource() on Android

30 Views Asked by At

I am trying to build an Android application which uses the XMLBeans library.

The library tries to look up .class-files via

ClassLoader cl = SchemaDocument.class.getClassLoader();
URL resource = cl.getResource("xyz.class");

It seems this does not work on Android, probably due to the dexclassloader and different packaging of code and resources in the .apk-files via "dex-files".

I agreed that this code is strange and should rather use Class.forName() properly, which seems to work. I will work with the library-devs to see if it can be changed.

But it would still be good to make this work somehow, so is there a way to make getResource("xyz.class") work on Android as well?

0

There are 0 best solutions below