重复条目:android / support / annotation / ColorRes.class

时间:2015-11-19 22:48:48

标签: android android-studio sdk dependencies

我收到此错误:

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

我在做什么?

1-multiDexEnabled

2 - 添加:配置{all * .exclude group:'com.android.support',module:'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:0.6.3.4@aar'
        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'
    }

}

2 个答案:

答案 0 :(得分:1)

这可能意味着您有多个依赖项要么实现相同的类,要么引用同一个类的不同版本(在不同的包中)。

前者可能正在发生,因为您从maven中包含了支持库: 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 并尝试将其作为Gradle依赖项:

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:0.6.3.4@aar'
        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')
    }

答案 1 :(得分:0)

如果您不需要support-annotations包,可以在build.gradle应用中将其排除:

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