简体   繁体   中英

Error: java.lang.NoClassDefFoundError: Failed resolution of: Lnu/xom/Builder - Xml to json converting not working


I am new to Android and doing a school project whereby I have to make my own app from scratch. I am doing an HTTPrequest towards an API, which gives me a dataset in xml back. I want to convert that to JSON for some reasons. I've already read a lot about the json-lib to convert the xml towards json, but I keep getting an error.

This is a part of my code, which causes the error:

 try {
    String xml = result;
    XMLSerializer xmlSerializer = new XMLSerializer();
    JSON json = xmlSerializer.read( xml ); 

I've implemented the following libraries:

  • apache-commons-lang.jar
  • json-lib-2.4-jdk15.jar
  • java-json.jar.zip

And I keep getting this error:

FATAL EXCEPTION: main

Process: com.example.josien.programmeerproject2, PID: 2813

java.lang.NoClassDefFoundError: Failed resolution of: Lnu/xom/Builder;

at net.sf.json.xml.XMLSerializer.read(XMLSerializer.java:309)

at com.example.jj.programmeerproject2.Train_AsyncTask.onPostExecute(Train_AsyncTask.java:68)

at com.example.jj.programmeerproject2.Train_AsyncTask.onPostExecute(Train_AsyncTask.java:20)

at android.os.AsyncTask.finish(AsyncTask.java:651)

at android.os.AsyncTask.-wrap1(AsyncTask.java)

at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)

at android.os.Handler.dispatchMessage(Handler.java:102)

at android.os.Looper.loop(Looper.java:148)

at android.app.ActivityThread.main(ActivityThread.java:5417)

at java.lang.reflect.Method.invoke(Native Method)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Caused by: java.lang.ClassNotFoundException: Didn't find class "nu.xom.Builder" on path: DexPathList[[dex file "/data/data/com.example.josien.programmeerproject2/files/instant-run/dex/slice-support-annotations-23.4.0_00b8b06029b068a524b039060787b6e287c3e6d2-classes.dex"

Of course I googled a lot about this error, but unfortunately I can't find the answer. Can anyone help me? Would be really appreciated!

The error:

java.lang.ClassNotFoundException: Didn't find class "nu.xom.Builder" on path: DexPathList[[dex file "/data/data/com.example.josien.programmeerproject2/files/instant-run/dex/slice-support-annotations-23.4.0_00b8b06029b068a524b039060787b6e287c3e6d2-classes.dex"

This means that the class Builder is not found in your project setup. I think that you are trying to use a jar file, without having the project setup properly to use the jar file. If you want more information, I would need to know exactly how your project is setup (uml diagram, a diagram showing the file structure of the project, as well as the project's settings).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM