exception while using ksoap2 library for android

Manoj picture Manoj · Apr 18, 2011 · Viewed 13.1k times · Source

I'm using Ksoap2 version 2.5.4 in my maven enabled android Project. Any reference to the Ksoap specific classes is throwing this exception

04-18 20:35:15.429: ERROR/dalvikvm(626): Could not find class 'org.ksoap2.serialization.SoapObject', referenced from method com.rare.Main.fetchSoapResponse
04-18 20:35:15.662: ERROR/AndroidRuntime(626): FATAL EXCEPTION: main
04-18 20:35:15.662: ERROR/AndroidRuntime(626): java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject
04-18 20:35:15.662: ERROR/AndroidRuntime(626):     at com.rare.Main.fetchSoapResponse(Main.java:57)
04-18 20:35:15.662: ERROR/AndroidRuntime(626):     at com.rare.Main.onCreate(Main.java:23)
04-18 20:35:15.662: ERROR/AndroidRuntime(626):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-18 20:35:15.662: ERROR/AndroidRuntime(626):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-18 20:35:15.662: ERROR/AndroidRuntime(626):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-18 20:35:15.662: ERROR/AndroidRuntime(626):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-18 20:35:15.662: ERROR/AndroidRuntime(626):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-18 20:35:15.662: ERROR/AndroidRuntime(626):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-18 20:35:15.662: ERROR/AndroidRuntime(626):     at android.os.Looper.loop(Looper.java:123)
04-18 20:35:15.662: ERROR/AndroidRuntime(626):     at android.app.ActivityThread.main(ActivityThread.java:3683)
04-18 20:35:15.662: ERROR/AndroidRuntime(626):     at java.lang.reflect.Method.invokeNative(Native Method)
04-18 20:35:15.662: ERROR/AndroidRuntime(626):     at java.lang.reflect.Method.invoke(Method.java:507)
04-18 20:35:15.662: ERROR/AndroidRuntime(626):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-18 20:35:15.662: ERROR/AndroidRuntime(626):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-18 20:35:15.662: ERROR/AndroidRuntime(626):     at dalvik.system.NativeStart.main(Native Method)

the line of code causing this is

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

Couldn't find any help related to this on SO or other forums. This seems pretty straight forward. Can any one tell me whats missing and how I can make android use the library at run time.

Answer

Oguz Ozkeroglu picture Oguz Ozkeroglu · Apr 26, 2012
  • In your build path clear all libraries (jar files).
  • In project's main directory create a folder and named it "libs" (not "lib").
  • Now Eclipse ADT Plugin will add your jar files to build path.
  • Clean & Build your project if necessary.
  • Happy coding