Android uses ksoap2 to call WebService and correctly import jar packages

Source: Internet
Author: User

Error Message

Java. Lang. noclassdeffounderror: org. ksoap2.serialization. soapobject

[Java] View plain Copy Print ?
  1. Error/androidruntime (600): Java. Lang. noclassdeffounderror: org. ksoap2.serialization. soapobject
  2. At WebService. Weather. weatheractivity. getweather (weatheractivity. Java: 104)
  3. At WebService. Weather. weatheractivity. showweather (weatheractivity. Java: 84)
  4. At WebService. Weather. weatheractivity. Access $0 (weatheractivity. Java: 80)
  5. At WebService. Weather. weatheractivity $1. onclick (weatheractivity. Java: 75)
  6. At Android. View. View. javasmclick (view. Java: 2408)
  7. At Android. View. View $ custom mclick. Run (view. Java: 8816)
  8. At Android. OS. handler. handlecallback (handler. Java: 587)
  9. At Android. OS. handler. dispatchmessage (handler. Java: 92)
  10. At Android. OS. lorule. Loop (lorule. Java: 123)
  11. At Android. App. activitythread. Main (activitythread. Java: 4627)
  12. At java. Lang. Reflect. method. invokenative (native method)
  13. At java. Lang. Reflect. method. Invoke (method. Java: 521)
  14. At com. Android. Internal. OS. zygoteinit $ methodandargscaller. Run (zygoteinit. Java: 868)
  15. At com. Android. Internal. OS. zygoteinit. Main (zygoteinit. Java: 626)
  16. 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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.