【问题标题】:duplicate entry: com/android/volley/AuthFailureError.class while compiling project in android studio重复条目:com/android/volley/AuthFailureError.class 在 android studio 中编译项目时
【发布时间】:2016-05-10 07:35:12
【问题描述】:

我正在使用外部库 payu money sdk 和 linkedin-sdk,两者都使用 volley 库,在编译项目时会给出 AuthFailureError.class 的重复条目

错误:任务 ':app:packageAllDebugClassesForMultiDex' 执行失败。

java.util.zip.ZipException:重复条目:com/android/volley/AuthFailureError.class"

我还添加了以下代码来排除模块,但仍然是同样的错误

configurations{ all*.exclude module: 'com.android.volley' }

请帮忙

【问题讨论】:

  • @Ankur 你有解决这个问题的方法吗?请尽快回复。
  • @Dev...是的,在经历了这么多麻烦之后..我在排除 support-v4 库 compile('com.android.support:appcompat-v7:23.2.1') { exclude module: 'support-v4' } compile('com.google.android.gms:play-services:8.3.0') { exclude module: 'support-v4' } 的情况下做到了这一点,如果它不起作用,请告诉我哪些库正在制造问题。
  • 我也有同样的问题,请问我该如何解决?

标签: android android-studio android-build


【解决方案1】:

我偶然发现了同样的错误,在阅读了this 之后,我能够解决它。

尝试在您的应用程序目录build.gradle 文件中添加这一行 -

android{
configurations {
    all*.exclude group: 'com.android.volley'
}}

希望这会有所帮助。

【讨论】:

    【解决方案2】:

    我在尝试生成 APK(发布)时遇到了这个问题,我通过更改 linkedin-sdk build.gradle 解决了这个问题:

    发件人:

    dependencies {
        compile 'com.android.support:support-annotations:20.0.0'
        compile 'com.android.support:support-v4:21.0.+'
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile files('libs/volley.jar')
        androidTestCompile('junit:junit:4.12') }
    

    收件人:

    dependencies {
        compile 'com.android.support:support-annotations:20.0.0'
        compile 'com.android.support:support-v4:21.0.+'
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.volley:volley:1.0.0'
        androidTestCompile('junit:junit:4.12') }
    

    【讨论】:

      【解决方案3】:

      在你的gradle文件的defaultConfig部分添加multiDexEnabled true

      那么,

      在你的依赖中编译'com.android.support:multidex:1.0.1'

      最后在您的应用程序类中添加以下内容:

       @Override
          protected void attachBaseContext(Context base) {
              super.attachBaseContext(base);
              MultiDex.install(this);
          }
      

      另外,请检查您是否在 libs 文件夹中使用 volley.jar。如果是这样,请删除该 jar 文件,然后重新编译。有时,jar 依赖项与使用远程源编译的依赖项发生冲突。

      【讨论】:

      • 但如果我从 libs 文件夹中删除该 jar 文件,我的代码将无法运行,它会给出找不到 volley 的错误
      • 在使用 Volley 的依赖项中尝试“排除组 com.google.volley”模块。
      • 仍然是同样的错误..我在使用 volley 库的两个库中都使用了这个compile ('com.mcxiaoke.volley:library:1.0.18'){ exclude group: 'com.google.volley' }....也使用 CMD+O 它表明 AuthFailure 类属于'com.android.volley ' 组,将 com.google.volley 更改为 com.android.volley.. 后仍然无效
      【解决方案4】:

      这是一个示例,当 gradle 中有重复条目时,如何排除依赖项中的类。

       compile ('com.google.api-client:google-api-client-android:1.17.0-rc') {
          exclude module: 'httpclient'
       }
      

      或者尝试你的方式,只是添加更多的文字

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

      所以,现在你要做的是

      在 android studio 中按 CTRL+SHIFT+N 搜索类 AuthFailureError.class 查看哪个 jar 包含它并像上面一样将其删除(这仅作为示例/您必须找出重复的类并手动删除它)

      【讨论】:

      • configurations{ all*.exclude group: 'com.android.volley', module: 'library-1.0.18' } 仍然存在同样的错误,当我将排除模块添加到我的 build.gradle 时,它​​会给出错误“未找到 Gradle DSL 方法:'exclude()'”
      【解决方案5】:

      只需删除重复的jar文件(注意:使用新版本,删除旧版本)用于在build.gradle中导入“com.android.volley.AuthFailureError”。然后清理项目并重建项目,然后运行你会得到结果。

      【讨论】:

      • 不能删除文件,因为它们在外部库中,需要排除
      【解决方案6】:

      我在 Jenkins 上构建时遇到了类似的问题,奇怪的是它在我的本地机器上运行良好。添加以下排除后,它可以在本地机器和 Jenkins 上运行。

      android{
      configurations {
          all*.exclude group: 'com.android.volley'
      }}
      

      我已将配置块添加到我的应用程序的 android 部分的 build.gradle 中。

      如果重要的是编译 SDK 版本是 22,构建工具版本是 25.0.0

      这就像一个魅力。

      【讨论】:

        【解决方案7】:

        好的,我知道了

        在mac上而不是控制n,它是命令0,我需要的命令是

        配置{ all*.exclude 模块:'volley-release' }

        【讨论】:

          【解决方案8】:

          只需从依赖项中删除您的 volley 库即可。 尝试清理并重建对我有用的项目。 前任。 payusdk 也在实施 volley 库,因此这就是异常显示重复条目的原因。我希望它有效。因为我也发现了这个错误并且我做这些事情它有效。 谢谢。

          【讨论】:

            【解决方案9】:

            在 Android Studio 终端中使用以下命令获取依赖冲突数据 - [替换为您的应用名称]

            ./gradlew -q :<app>:dependencyInsight --dependency volley --configuration compile
            

            如果您使用来自 android [https://github.com/google/volley/releases] 的最新 Volley 库,请在您的 build.gradle 文件中的每个有冲突的编译库条目下添加以下两行。

            例如:

            compile('com.xyz:abc:1.1.0-RELEASE') {
                    exclude module: 'library'
                    exclude group: 'com.mcxiaoke.volley'
            }
            

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2014-11-27
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多