2015-11-19 34 views
0

我得到這個錯誤:重複的條目:安卓/支持/註解/ ColorRes.class

Error:Execution failed for task ':mobile:packageAllDebugClassesForMultiDex'. 
> java.util.zip.ZipException: duplicate entry: android/support/annotation/ColorRes.class 

我在做什麼?

1- multiDexEnabled

2-補充一點:配置{所有* .exclude組: 'com.android.support',模塊: '支持-V4'}和沒有工作(另一個重複條目錯誤)

3-逐個刪除依賴關係。不工作或收到其他錯誤

4 - 排除依賴逐個並不起作用

screenshot

可能是什麼問題呢?

的build.gradle

apply plugin: 'com.android.application' 


    dependencies 
    { 
     compile 'com.android.support:support-v4:22.2.1' 
     compile 'com.android.support:appcompat-v7:22.2.1' 
     compile 'com.android.support:cardview-v7:21.0.3' 
     compile 'com.android.support:recyclerview-v7:21.0.3' 
     compile 'com.android.support:multidex:1.0.1' 
     compile 'com.google.android.gms:play-services:8.3.0' 
     compile 'com.google.maps.android:android-maps-utils:0.4' 
     compile 'com.afollestad:material-dialogs:[email protected]' 
     compile 'com.bignerdranch.android:recyclerview-multiselect:0.1' 
     compile 'com.j256.ormlite:ormlite-android:4.48' 
     compile 'com.melnykov:floatingactionbutton:1.2.0' 
     compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3' 
     compile 'se.emilsjolander:StickyScrollViewItems:1.1.0' 
     compile fileTree(include: ['*.jar'], dir: 'libs') 
     compile files('libs/appodeal-1.13.10.jar') 
     compile files('libs/applovin-6.1.4.jar') 
     compile files('libs/inmobi-5.0.1.jar') 
     compile files('libs/android-support-v4-22.2.1.jar') 
     compile files('libs/my-target-4.1.2.jar') 
     compile files('libs/yandex-metrica-android-2.00.jar') 
    } 

android 
{ 
compileSdkVersion 22 
buildToolsVersion "22.0.1" 


defaultConfig 
{ 
    minSdkVersion 15 
    targetSdkVersion 22 
    versionCode VERSION_MAJOR*10000000 + VERSION_MINOR*100000 +  VERSION_PATCH*1000 + VERSION_BUILD 
    versionName "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" 

    // Enabling multidex support. 
    multiDexEnabled true 

    configurations { 
     all*.exclude group: 'com.android.support', module: 'support-v4' 
    } 

} 
+0

不能肯定地說,但我的猜測是它的相關的支持庫使用多個不同的版本號, – Brucelet

+1

@Brucelet謝謝,改變所有的第EM到22,但不起作用 –

回答

1

這可能意味着你有多個依賴一個實現同一類或同一類的引用不同的版本(在不同的包)。

前者可能發生的,因爲你包括支持庫無論是從行家: compile 'com.android.support:support-v4:22.2.1' ,並從本地文件系統:compile files('libs/android-support-v4-22.2.1.jar')。我建議刪除本地依賴。

如果您混合使用不同的Android支持依賴項版本,後者可能會發生。在你的情況你混合CardView和RecyclerView的舊版本與新根的支持庫: compile 'com.android.support:appcompat-v7:22.2.1' compile 'com.android.support:cardview-v7:21.0.3'

嘗試使所有com.android.support依賴的參考建22.2.1。

把所有在一起,刪除項目的本地文件libs/android-support-v4-22.2.1.jar並試圖以此作爲您的搖籃依賴關係:

dependencies 
    { 
     compile 'com.android.support:support-v4:22.2.1' 
     compile 'com.android.support:appcompat-v7:22.2.1' 
     compile 'com.android.support:cardview-v7:22.2.1' 
     compile 'com.android.support:recyclerview-v7:22.2.1' 
     compile 'com.android.support:multidex:1.0.1' 
     compile 'com.google.android.gms:play-services:8.3.0' 
     compile 'com.google.maps.android:android-maps-utils:0.4' 
     compile 'com.afollestad:material-dialogs:[email protected]' 
     compile 'com.bignerdranch.android:recyclerview-multiselect:0.1' 
     compile 'com.j256.ormlite:ormlite-android:4.48' 
     compile 'com.melnykov:floatingactionbutton:1.2.0' 
     compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3' 
     compile 'se.emilsjolander:StickyScrollViewItems:1.1.0' 
     compile fileTree(include: ['*.jar'], dir: 'libs') 
     compile files('libs/appodeal-1.13.10.jar') 
     compile files('libs/applovin-6.1.4.jar') 
     compile files('libs/inmobi-5.0.1.jar') 
     compile files('libs/my-target-4.1.2.jar') 
     compile files('libs/yandex-metrica-android-2.00.jar') 
    } 
+0

謝謝,當我刪除android-support-v4-22.2.1.jar我得到幾個這樣的錯誤:錯誤:(19,31)錯誤:包android.support.v4.view不存在 –

+0

它看起來像你從你的構建中排除。 – mszaro

+0

嘗試刪除此:'所有* .exclude組:'com.android.support',模塊:'support-v4' } – mszaro

0

如果你不需要支持的註解包,你可以在你build.gradle排除應用:

android{ 
    ... 
    configurations { 
     all*.exclude group: 'com.android.support', module: 'support-annotations' 
    } 
} 
相關問題