Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dalvik VM error: Exception found "Javax.xml.namespace.QName.class"

This isn't intended to be a question. Rather, an observation which is a common problem found in Android when you use external APIs for development and android.jar isn't duplicated into your project!

like image 426
curlyreggie Avatar asked Apr 10 '12 23:04

curlyreggie


1 Answers

After searching through various forums, Google and stackoverflow, I seem to get a solution by myself and thought of sharing it.

  1. Whenever you are linking external libraries, better link it by creating a /lib folder and dump those .jars there(means to COPY the files and NOT linking them). Link them using Eclipse -> Build Properties -> Configure Build path -> Library tab -> Add external Jars. Add the required .jars saved in /lib folder in this. (Note that, the jar included as a "Referenced Library" in Eclipse will disappear in /lib folder! But, not to worry as proper linking has happened. Another note is to check that the /lib jar that was referenced should NOT be visible in Libraries tab of Build Properties as it will be inherited.)

  2. Another major problem was when Google APIs are being used. Specially the ones, which use some core library functions of java/javax. Be very careful of this. The error is that, the DalvikVM tries to link these but fails as there is a duplication found and is unable to decide which one to refer to. Below is the error.

    Dx trouble processing "javax/xml/namespace/QName.class": 
    Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library.
    

In such cases, what I have observed is that, this class is used in xpp3-1.1.4c.jar. If you've copied this into your /lib folder, PLEASE REMOVE IT. Then clean the project, and give a fresh build. And the ship sails smoothly thereafter.

Do this for other referenced .jars if such duplication exists.

Cheers!

like image 103
curlyreggie Avatar answered Sep 19 '22 20:09

curlyreggie