2017-04-14 132 views
1

我用wsimport从wsdl生成类。现在我解决缺少的依赖关系,其中一些属于javax.xml.ws:jaxws-api:android jaxws-api依赖导致冲突

import javax.xml.ws.Service; import javax.xml.ws.WebServiceException; import javax.xml.ws.WebServiceFeature; gradle这个构建失败当我添加了依赖性:

错误:与冲突相依“的javax .annotation:项目中的javax.annotation-api':app'。应用程序(1.2-b03)和测试应用程序(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/AttachmentP art.class“: 错误:建议或错误地使用核心类(java。*或javax。*) 错误:未构建核心库时。 ....

回答

0

build.gradle应用程序中的这些代码是扼杀者。

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    testCompile 'junit:junit:4.12' 

删除它们之后gradle compire错误就解决了。 另外检查外部库...额外的javax.annotation-api-1.2不存在了。享受!