我正在使用Ksoap2库来处理soap webservices。但是是gettig错误没有类定义发现问题。有人可以解释这个问题的确切原因和解决方案。我在libs文件夹中添加了Ksoap2 jar并右键单击并选择添加为库选项。下面是我的代码。
下面是我的摇篮:
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation files('libs/ksoap2-android-2.5.2.jar')
}
下面是我的webserive哈德林代码:
SoapObject request = new SoapObject(NAMESPACE,METHOD_GET_PO);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
request.addProperty("uCode", mUCode);
envelope.dotNet = true;// to handle .net services asmx/aspx
envelope.setOutputSoapObject(request);
HttpTransportSE ht = new HttpTransportSE(URL_PROTOCOL+ settings.getSettings_Serverpath() + URL_SERVICE_NAME);
ht.debug = true;
String soap_action = NAMESPACE + METHOD_GET_PO;
ht.call(soap_action, envelope);
SoapPrimitive resultString = (SoapPrimitive) envelope.getResponse();
我收到以下错误:
--------- beginning of crash
2019-07-25 15:55:49.766 12018-12064/com.example.sivabala.visualporeceiving E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.example.sivabala.visualporeceiving, PID: 12018
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:354)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:914)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/kxml2/io/KXmlSerializer;
at org.ksoap2.transport.Transport.createRequestData(Transport.java:80)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:79)
at com.example.sivabala.visualporeceiving.CI.controller.LoginActivity$GetPO.doInBackground(LoginActivity.java:184)
at com.example.sivabala.visualporeceiving.CI.controller.LoginActivity$GetPO.doInBackground(LoginActivity.java:149)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:914)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.kxml2.io.KXmlSerializer" on path: DexPathList[[zip file "/data/app/com.example.sivabala.visualporeceiving-yscH3NKMSUtvYDIdp2ANSQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.sivabala.visualporeceiving-yscH3NKMSUtvYDIdp2ANSQ==/lib/x86, /system/lib, /system/product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:195)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at org.ksoap2.transport.Transport.createRequestData(Transport.java:80)
at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:79)
at com.example.sivabala.visualporeceiving.CI.controller.LoginActivity$GetPO.doInBackground(LoginActivity.java:184)
at com.example.sivabala.visualporeceiving.CI.controller.LoginActivity$GetPO.doInBackground(LoginActivity.java:149)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:914)
答案 0 :(得分:0)