【问题标题】:duplicate entry: android/support/annotation/AnyRes.class重复条目:android/support/annotation/AnyRes.class
【发布时间】:2016-01-07 03:01:57
【问题描述】:

我不确定这个错误是什么意思。

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

这是我的库依赖项

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.squareup.picasso:picasso:2.5.2'
     compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.ms-square:etsyblur:0.1.2'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:cardview-v7:22.2.0'
    compile 'com.android.support:recyclerview-v7:22.2.0'
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.squareup.okhttp:okhttp:2.0.0'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.google.code.gson:gson:2.3'
    compile 'org.apache.commons:commons-lang3:3.3.2'
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'com.marshalchen.ultimaterecyclerview:library:0.3.4'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.facebook.android:facebook-android-sdk:4.1.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.android.gms:play-services-analytics:8.1.0'
    compile 'joda-time:joda-time:2.8.2'
    compile 'com.google.android.gms:play-services-identity:8.1.0'
    compile 'com.google.android.gms:play-services-plus:8.1.0'
}

任何帮助将不胜感激。

【问题讨论】:

  • 您是否已将任何 jars 添加到您的 libs 文件夹中,或者您是否也可以列出它们?
  • 我在 libs 文件夹中有 httpclient-4.3.6.jar httpcore-4.3.3.jar httpmime-4.3.6.jar

标签: android duplicates android-gradle-plugin android-multidex


【解决方案1】:

Android 中的任何 duplicate entry 错误发生是因为您有 2 倍或更多倍的相同 library 可用、独立或包含在另一个库中

【讨论】:

  • 那又怎样。 Gradle 应该优雅地处理 exclude 语句。
【解决方案2】:

当您使用 v7 时,请尝试从您的 gradle 文件中删除支持 v4

【讨论】:

    【解决方案3】:

    如果你运行 ./gradlew -q app:dependencies,你会发现 play-services 库有大量的传递依赖。为了缓解这种情况,请在 build.gradle 中添加以下内容:

    compile ('com.google.android.gms:play-services:8.1.0') { exclude group: 'com.android.support', module: 'support-annotations' }

    【讨论】:

      猜你喜欢
      • 2016-02-22
      • 2016-02-09
      • 2016-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多