我使用wsimport从wsdl生成类。现在我正在解决缺少的依赖项,其中一些属于javax.xml.ws:jaxws-api:
添加依赖项时, import javax.xml.ws.Service;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;
gradle构建失败:
错误:与依赖项冲突&javax.annotation:javax.annotation-api'在项目':app'。 app(1.2-b03)和测试app(1.2)的已解决版本有所不同。有关详细信息,请参阅http://g.co/androidstudio/app-test-app-conflict。
为什么这种依赖会导致这个奇怪的错误?我尝试更改版本并从build.gradle中删除一些其他依赖项,但没有。这是我的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.prova"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.2'
compile 'javax.xml.bind:jaxb-api:2.2.11'
compile 'javax.xml.ws:jaxws-api:2.2.11'//this is causing conflict
}
非常感谢你的帮助
修改
我尝试添加以下内容:
configurations.all{
resolutionStrategy.force 'javax.annotation:javax.annotation-api:1.2'
}
但又犯了一个奇怪的错误:
错误:处理错误" javax / xml / soap / AttachmentPart.class": 错误:错误使用或错误使用核心类(java。*或javax。*) 错误:未构建核心库时。 ....
答案 0 :(得分:0)
These codes in the build.gradle app was the culpit.
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
after removing them gradle compire error solved. Also check external Libraries..that extra javax.annotation-api-1.2 isnt there anymore.Enjoy!!