[英]how to solve the conflict in jar files dependencies in Android studio
大家好,我有一個項目,在導入speedchecker庫后,我今天從eclipse遷移到了android studio,它顯示了
speedchecker-android-sdk-1.2.jar
httpcore-4.3-beta1.jar
httpclient-4.3-beta1.jar
httpclient-cache-4.3-beta1.jar
httpmime-4.3-beta1.jar
在某些班級上有沖突。 這些是我的依賴
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:multidex:1.0.1'
compile('com.octo.android.robospice:robospice-google-http-client:1.4.14') {
exclude module: 'commons-io'
exclude group: 'org.apache.commons'
}
compile('com.google.http-client:google-http-client-jackson2:1.19.0') {
exclude module: 'commons-io'
exclude module: 'xpp3'
exclude group: 'stax'
}
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.code.gson:gson:2.6.2'
compile files('libs/activation.jar')
//conflict in here
compile files('libs/speedchecker-android-sdk-1.2.jar')
compile files('libs/httpcore-4.3-beta1.jar')
compile files('libs/httpclient-4.3-beta1.jar')
compile files('libs/httpclient-cache-4.3-beta1.jar')
compile files('libs/httpmime-4.3-beta1.jar')
compile files('libs/additionnal.jar')
compile files('libs/facebook1.jar')
compile files('libs/mail.jar')
compile files('libs/universal-image-loader-1.9.5.jar')
compile files('libs/gcm.jar')
}
你能幫我么
使用app:dependencies
查看依賴關系樹。 通常會指出在堆棧跟蹤中哪個類有沖突。 搜索那個並將其從您的依賴項之一中排除。
打開Gradle
窗口,然后單擊execute Task
(它是一個圖標)。 輸入app:dependencies
,您將在“ Messages
窗口中看到您的gradle樹。
搜索沖突的類並將其排除在外,例如:
compile('commons-validator:commons-validator:1.5.0') {
exclude group: 'commons-logging', module: 'commons-logging'
}
您可以通過清單通過重寫庫來解決沖突,如下所示:
例如,在主要的Android清單中:
<uses-sdk android:targetSdkVersion="14" android:minSdkVersion="2"
tools:overrideLibrary="com.example.lib1, com.example.lib2"/>
工具:覆蓋庫標記
一個特殊標記,只能與uses-sdk聲明一起使用,以覆蓋導入其最低SDK版本比該應用程序的最低SDK版本新的庫。 沒有這樣的標記,清單合並將失敗。 該標記將允許用戶選擇要導入的庫,而無需考慮最低的SDK版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.