Error Message
Java. Lang. noclassdeffounderror: org. ksoap2.serialization. soapobject
[Java]
View plain
Copy
Print
?
- Error/androidruntime (600): Java. Lang. noclassdeffounderror: org. ksoap2.serialization. soapobject
- At WebService. Weather. weatheractivity. getweather (weatheractivity. Java: 104)
- At WebService. Weather. weatheractivity. showweather (weatheractivity. Java: 84)
- At WebService. Weather. weatheractivity. Access $0 (weatheractivity. Java: 80)
- At WebService. Weather. weatheractivity $1. onclick (weatheractivity. Java: 75)
- At Android. View. View. javasmclick (view. Java: 2408)
- At Android. View. View $ custom mclick. Run (view. Java: 8816)
- At Android. OS. handler. handlecallback (handler. Java: 587)
- At Android. OS. handler. dispatchmessage (handler. Java: 92)
- At Android. OS. lorule. Loop (lorule. Java: 123)
- At Android. App. activitythread. Main (activitythread. Java: 4627)
- At java. Lang. Reflect. method. invokenative (native method)
- At java. Lang. Reflect. method. Invoke (method. Java: 521)
- At com. Android. Internal. OS. zygoteinit $ methodandargscaller. Run (zygoteinit. Java: 868)
- At com. Android. Internal. OS. zygoteinit. Main (zygoteinit. Java: 626)
- At Dalvik. system. nativestart. Main (native method)
Solution
After finding a lot of information, I finally found that there was a problem with importing the jar package .... The following method is used to import jar packages during Java program development:
Right-click the project and choose build path> Add libraries> User library> select the library that contains the required jar package. (if not, click User libraries to create a new library, and then select)
However, importing a jar package in Android causes java. Lang. noclassdeffounderror to be thrown when the program runs in the simulator. The steps for importing a jar package in Android are as follows:
Right-click the project and choose>Build path-> Add External Archives-> select the jar package to import
Another problem is that the android simulator cannot use localhost or local IP address when accessing the WebService program deployed on Tomcat. The default address for Android to access the local machine is 10.0.2.2.
None of the above solutions works:
New Solution:
Create a new folder libs in the project, copy the jar package of ksoap2 to this folder, right-click the jar package, and choose build path --> Add to build path.