Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
109 views
in Technique[技术] by (71.8m points)

Android core library error

When I am including the jaxp.jar, I get the following error-

trouble processing "javax/xml/XMLConstants.class":
[2009-05-08 16:53:18 - TestProject] 
Attempt to include a core VM class in something other than a core library.
It is likely that you have attempted to include the core library from a desktop
virtual machine into an application, which will most assuredly not work. If
you really intend to build a core library -- which is only appropriate as
part of creating a full virtual machine binary, as opposed to compiling an
application -- then use the "--core-library" option to suppress this error
message. If you go ahead and use "--core-library" but are in fact building
an application, then please be aware that your build will still fail at some
point; you will simply be denied the pleasure of reading this helpful error
message.
[2009-05-08 16:53:18 - TestProject] 1 error; aborting
[2009-05-08 16:53:18 - TestProject] Conversion to Dalvik format failed with error 1

Has anyone faced this problem? Any help will be really appreciated I have gone with some solutions but they are not specific.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...