我正在使用SOAP将请求发送到Web服务的android应用程序上工作。在使用junit进行测试时,代码可以正常工作,但是在任何设备上部署应用程序时,都会出现错误java.lang.NoClassDefFoundError: com.sun.xml.messaging.saaj.soap.SOAPDocumentImpl
我尝试将这种依赖关系添加到应用implementation 'com.sun.xml.messaging.saaj:saaj-impl:1.4.0'
的build.grade文件中,但这不能解决问题。
repositories {
maven { url 'https://mvnrepository.com/artifact/javax.xml.soap/saaj-api' }
maven { url 'https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple' }
maven { url 'https://mvnrepository.com/artifact/com.sun.xml.messaging.saaj/saaj-impl' }
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.jkuber.gov.jkuberpayeeportal"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'javax.xml.soap:saaj-api:1.3.5'
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
implementation 'androidx.room:room-runtime:2.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.sun.xml.messaging.saaj:saaj-impl:1.4.0'
implementation ('junit:junit:4.12'){
exclude group: 'org.hamcrest', module:'hamcrest-core'
}
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}