dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile('com.google.android.gms:play-services-gcm:8.4.0') {
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.google.android.gms'
}
compile ('com.google.android.gms:play-services-base:8.4.0') {
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.google.android.gms'
}
compile('com.android.support:appcompat-v7:23.2.0') {
exclude module: 'animated-vector-drawable'
}
compile 'com.jakewharton:butterknife:7.0.1'
compile 'se.emilsjolander:stickylistheaders:2.7.0'
compile 'com.google.code.gson:gson:2.5'
compile('com.koushikdutta.ion:ion:2.+') {
exclude module: 'gson'
}
compile 'com.github.JakeWharton:ViewPagerIndicator:[email protected]'
compile 'com.github.androidprogresslayout:library:[email protected]'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:[email protected]'
}
但每次我得到這個錯誤:搖籃錯誤:執行失敗的任務 ':應用程序:transformClassesWithJarMergingForDebug'
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException:
java.util.zip.ZipException:
duplicate entry: android/support/v4/widget/SimpleCursorAdapter$CursorToStringConverter.class
下面是gradlew -q dependencies App:dependencies --configuration compile
結果:
從底部,你可以看到,我還沒有添加com.google.android.gms:play-services-measurement
庫,但它顯示沒有理由?
找到了解決辦法
我的gradle檢查的控制檯,而其德興的依賴,我看到了;
Dexing \app\build\intermediates\exploded-aar\com.github.JakeWharton\ViewPagerIndicator\2.4.1\jars\libs\android-support-v4.jar took 1499
哪個是最舊的support-v4 lib作爲jar添加的。我已經從build.gradle中刪除了ViewPagerIndicator依賴項,並手動添加它的類。
現在最奇怪的問題解決了。
您是否使用了一些罐子? –
@GabrieleMariotti其實我沒有使用任何罐子。但不知何故,我創建了一個新的空項目,並將類和res文件複製到新項目中。雖然gradle是德興,我看到Dexing \ app \ build \ intermediates \ exploded-aar \ com.github.JakeWharton \ ViewPagerIndicator \ 2.4.1 \ jars \ libs \ android-support-v4.jar花了1499年 這是添加支持-v4罐最老的一個。我從依賴項列表中刪除了viewpagerindicator lib並手動添加了它的類。現在奇怪的問題解決了。 –
這並不奇怪。您使用兩次不同的版本添加了同一個類 –