Android ksoap2 库在 SoapObject 上抛出 NoClassDefFoundError 异常
Android ksoap2 library throwing NoClassDefFoundError exception on SoapObject
关于这个 crash/bug 有很多 SO 问题,但它们要么与 eclipse 相关,要么对我不起作用。我有一个具有以下依赖项的项目
repositories {
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases' }
}
dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.5.7@aar') {
transitive = true;
}
compile('com.squareup.retrofit2:retrofit:2.0.0') {
//exclude web sockets module from okhttp
exclude module: 'okhttp-ws'
exclude module: 'okhttp'
}
configurations {
compile.exclude group: 'org.json', module: 'json'
}
compile files('libs/smack-core-4.1.7.jar')
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:customtabs:24.2.1'
compile 'com.google.guava:guava:18.0'
compile 'com.github.amlcurran.showcaseview:library:5.0.0'
compile 'com.koushikdutta.async:androidasync:2.1.4'
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.0'
compile 'xpp3:xpp3:1.1.4c'
compile 'org.jxmpp:jxmpp-core:0.4.2'
compile 'org.igniterealtime.smack:smack-android-extensions:4.1.7'
compile 'org.igniterealtime.smack:smack-tcp:4.1.7'
compile 'io.realm:android-adapters:1.3.0'
compile 'com.orhanobut:logger:1.15'
compile 'com.github.clans:fab:1.6.4'
compile 'com.wang.avi:library:2.1.3'
compile 'org.jsoup:jsoup:1.9.2'
compile 'com.github.bumptech.glide:glide:3.7.0'
**compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.1'**
compile fileTree(include: ['*.jar'], dir: 'libs')
}
configurations {
compile.exclude module: 'smack-core'
compile.exclude module: 'gson'
all*.exclude group: 'xpp3', module: 'xpp3'
}
项目Gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "io.realm:realm-gradle-plugin:1.2.0"
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
我的项目运行正常,没有任何问题,但在我将 Android Studio 更新到 2.2 后,此崩溃仅发生在 pre-lollipop 设备上。我不确定这是由于 Android Studio 更新引起的。
Caused by: java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject
at com.webgreeter.livechat.networkcalls.SoapWebServices.checkAndLogin(SoapWebServices.java:256)
at com.webgreeter.livechat.ui.LoginAsyncTask.LoginProcess(LoginAsyncTask.java:84)
at com.webgreeter.livechat.ui.LoginAsyncTask.doInBackground(LoginAsyncTask.java:39)
at com.webgreeter.livechat.ui.LoginAsyncTask.doInBackground(LoginAsyncTask.java:21)
at android.os.AsyncTask.call(AsyncTask.java:288)
崩溃的实际代码是:
String METHOD_NAME = "CheckandLogin";
SoapObject so = new SoapObject(NAMESPACE, METHOD_NAME);
so.addProperty("username", operator.getName());
so.addProperty("password", operator.getPassword());
so.addProperty("licenseKey", operator.getLicenseKey());
试试这个:
String username = "your username";
PropertyInfo usernameProp = new PropertyInfo();
usernameProp.setName("username");
usernameProp.setValue(username);
usernameProp.setType(String.class);
so.addProperty(usernameProp);
在花费数小时和回溯代码后,我终于找到了错误的来源。这是一个依赖性问题,并且由于依赖性冲突而发生。没有任何消息、日志或错误指向这个方向。我删除了 Glide,它解决了这个问题。现在我在用毕加索
compile 'com.github.bumptech.glide:glide:3.7.0'
关于这个 crash/bug 有很多 SO 问题,但它们要么与 eclipse 相关,要么对我不起作用。我有一个具有以下依赖项的项目
repositories {
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases' }
}
dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.5.7@aar') {
transitive = true;
}
compile('com.squareup.retrofit2:retrofit:2.0.0') {
//exclude web sockets module from okhttp
exclude module: 'okhttp-ws'
exclude module: 'okhttp'
}
configurations {
compile.exclude group: 'org.json', module: 'json'
}
compile files('libs/smack-core-4.1.7.jar')
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:customtabs:24.2.1'
compile 'com.google.guava:guava:18.0'
compile 'com.github.amlcurran.showcaseview:library:5.0.0'
compile 'com.koushikdutta.async:androidasync:2.1.4'
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.0'
compile 'xpp3:xpp3:1.1.4c'
compile 'org.jxmpp:jxmpp-core:0.4.2'
compile 'org.igniterealtime.smack:smack-android-extensions:4.1.7'
compile 'org.igniterealtime.smack:smack-tcp:4.1.7'
compile 'io.realm:android-adapters:1.3.0'
compile 'com.orhanobut:logger:1.15'
compile 'com.github.clans:fab:1.6.4'
compile 'com.wang.avi:library:2.1.3'
compile 'org.jsoup:jsoup:1.9.2'
compile 'com.github.bumptech.glide:glide:3.7.0'
**compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.1'**
compile fileTree(include: ['*.jar'], dir: 'libs')
}
configurations {
compile.exclude module: 'smack-core'
compile.exclude module: 'gson'
all*.exclude group: 'xpp3', module: 'xpp3'
}
项目Gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "io.realm:realm-gradle-plugin:1.2.0"
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
我的项目运行正常,没有任何问题,但在我将 Android Studio 更新到 2.2 后,此崩溃仅发生在 pre-lollipop 设备上。我不确定这是由于 Android Studio 更新引起的。
Caused by: java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject
at com.webgreeter.livechat.networkcalls.SoapWebServices.checkAndLogin(SoapWebServices.java:256)
at com.webgreeter.livechat.ui.LoginAsyncTask.LoginProcess(LoginAsyncTask.java:84)
at com.webgreeter.livechat.ui.LoginAsyncTask.doInBackground(LoginAsyncTask.java:39)
at com.webgreeter.livechat.ui.LoginAsyncTask.doInBackground(LoginAsyncTask.java:21)
at android.os.AsyncTask.call(AsyncTask.java:288)
崩溃的实际代码是:
String METHOD_NAME = "CheckandLogin";
SoapObject so = new SoapObject(NAMESPACE, METHOD_NAME);
so.addProperty("username", operator.getName());
so.addProperty("password", operator.getPassword());
so.addProperty("licenseKey", operator.getLicenseKey());
试试这个:
String username = "your username";
PropertyInfo usernameProp = new PropertyInfo();
usernameProp.setName("username");
usernameProp.setValue(username);
usernameProp.setType(String.class);
so.addProperty(usernameProp);
在花费数小时和回溯代码后,我终于找到了错误的来源。这是一个依赖性问题,并且由于依赖性冲突而发生。没有任何消息、日志或错误指向这个方向。我删除了 Glide,它解决了这个问题。现在我在用毕加索
compile 'com.github.bumptech.glide:glide:3.7.0'