2017-04-14 140 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不存在了。享受!