There is trouble when using core class in android Dx trouble processing "javax/xml/bind/Binder.class" I do need the classes in javax.xml.* for developing web services, but it is not fully supported in Android. When I import these jars, there is no compile error shown in eclipse but the DX cannot process it. After I search on the Internet, it is said that we can use --core- library or use jarjar to repackage it. I have not found any tutorials for adding DX option in eclipse. I appreciate for any help solving it.
2 Answers
the error you get from Dx is based only on the java package names of the libs you are importing and nothing else.
the message can by summarized as: if you import a library in the java.* or javax.* namespace, it's very likely that it depends on other "core" libraries that are only provided as part of the JDK, and therefore won't be available in the Android platform. it's essentially preventing you from doing something stupid, which is accurate 99% of the time when you see that message.
now, of course, just because a java package starts with java.* or javax.* does not necessarily mean that it depends on the JDK proper. it may work perfectly fine in android. to get around the stupidity check, add the --core-library option to dx. change the last line of $ANDROID_HOME/platform-tools/dx
from,
exec java $javaOpts -jar "$jarpath" "$@"
to,
exec java $javaOpts -jar "$jarpath" --core-library "$@"
in my case, i was including a library that depended on Jackson, which depends on JAXB. for me, overriding the stupidity check was acceptable because the library's use of Jackson was only for JSON and not for XML serialization (i only include the JAXB API library, not the impl). of course i wish there was a cleaner way to go about this, but re-writing the top level library to avoid using Jackson was not an option.

- 22,176
- 9
- 79
- 134
Those classes are compiled against an jvm incompatible with android dalvik. You will need to get the sources, not the jars, and compile them into jar files compiled for android.

- 5,554
- 1
- 24
- 30