Exception when using ksoap2 library for Android

I am using Ksoap2 version 2.5.4 in my Android Android project with maven support. Any reference to specific Ksoap classes throws 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) 

a line of code calling this

 SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

Could not find help related to this on SO or other forums. It seems pretty straight forward. Can someone tell me what is missing, and how can I make an android, use the library at runtime.

+6
source share
2 answers
  • In your build path, clear all libraries (jar files).
  • In the main directory of the project, create a folder and name it "libs" (not "Lib").
  • Now Eclipse ADT Plugin will add your jar files to create the path.
  • Clean and create a project if necessary.
  • Happy coding
+16
source

I had the same problem. I added a ZIP file instead of a jar file to an external library, you only need to add the JAR file.

+1
source

Source: https://habr.com/ru/post/886182/


All Articles