내 안드로이드 프로젝트에 ksoap2를 추가하려고했습니다. 아래는 내 build.gradle 파일입니다.
apply plugin: 'com.android.application'
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/'
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.rsa.mobile.android.transactionsigningsdk"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile('com.thoughtworks.xstream:xstream:1.4.7') {
exclude group: 'xmlpull'
}
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile ('com.google.code.ksoap2-android:ksoap2-android:3.0.0')
}
프로젝트는 오류없이 잘 컴파일되지만 내 기기에서 앱을 실행할 때 아래 오류가 발생합니다.
Information:Gradle tasks [:app:generateDebugSources,
:app:generateDebugAndroidTestSources, :app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preRele
aseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72310Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2310Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72310Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42310Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl UP-TO-DATE
:app:processDebugAndroidTestManifest UP-TO-DATE
:app:compileDebugAndroidTestRenderscript UP-TO-DATE
:app:generateDebugAndroidTestBuildConfig UP-TO-DATE
:app:generateDebugAndroidTestAssets UP-TO-DATE
:app:mergeDebugAndroidTestAssets UP-TO-DATE
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources UP-TO-DATE
:app:mergeDebugAndroidTestResources UP-TO-DATE
:app:processDebugAndroidTestResources UP-TO-DATE
:app:generateDebugAndroidTestSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:preDexDebug UP-TO-DATE
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lorg/xmlpull/v1/XmlPullParser;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 4.485 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
나는 그러한 오류에 대해 거의 모든 관련 질문을 찾았지만 아무것도 작동하지 않습니다. 나는 시도했다 :
1) 프로젝트 청소
2) 추가
android {
dexOptions {
preDexLibraries = false
}
}
내 gradle 파일에
3) 추가
{
exclude group: 'xmlpull'
}
다른 많은 것들이 있지만 도움이되지는 않습니다. 또한 ksoap2만으로 새로운 안드로이드 프로젝트를 만들었고 잘되었습니다. 아래는 작동하는 build.gradle입니다.
apply plugin: 'com.android.application'
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/'
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.rsa.mobile.test_ksoap"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.google.code.ksoap2-android:ksoap2-android:3.0.0'
}
함께 사용할 때 문제를 일으키는 xstream 및 ksoap2이 문제를 해결하는 방법에 대한 단서가 없습니다. 서로없이 사용하면 내 코드가 작동합니다.
누군가 제발 도와주세요. 나는 지금까지 내가 할 수있는 모든 것을 전혀 운없이했다.
마침내 해결책을 알아낼 수있었습니다. ksoap2 종속성을 추가하는 동안 제외 그룹 : 'xmlpull'대신 exclude 모듈 : 'xmlpull'을 추가해야합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다