【问题标题】:Duplicate entry error in my Android app我的 Android 应用程序中出现重复输入错误
【发布时间】:2017-02-13 14:45:36
【问题描述】:

同步 gradle 文件时出现此错误

错误:任务 ':app:transformClassesWithJarMergingForDebug' 执行失败。 com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com/google/zxing/client/android/camera/CameraConfigurationUtils.class

我尝试清理项目,重建项目和multidex,不包括模块。

我的 min sdk 是 19。如果大于 20,multidex 工作正常, 但在 SDK 19 中它不起作用。

这是我的 gradle 构建文件:

apply plugin: 'com.android.application'

android 
{

    compileSdkVersion 24
    buildToolsVersion '25.0.2'

    defaultConfig 
    {
        applicationId "com.example.prototype_01"
        minSdkVersion 19
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes 
    {
        release 
        {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies 
{
  compile fileTree(include: ['*.jar'], dir: 'libs')
  testCompile 'junit:junit:4.12'
  compile 'com.android.support:appcompat-v7:24.1.1'
  compile 'com.android.support:design:24.1.1'
  compile 'com.google.android.gms:play-services-appindexing:9.6.1'
  compile 'com.android.support:multidex:1.0.0'
  compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
  compile 'com.google.zxing:core:3.2.0'
  compile 'com.github.bumptech.glide:glide:3.5.1'
  //compile files('libs/android-core-3.2.1.jar')
  compile 'com.android.support:support-v4:24.2.1'
  compile 'com.tsengvn:Typekit:1.0.0'
  compile 'com.google.firebase:firebase-messaging:9.6.1'
}
apply plugin: 'com.google.gms.google-services'

有什么办法可以解决这个问题?

【问题讨论】:

    标签: android android-gradle-plugin build.gradle


    【解决方案1】:

    与Multidex无关。

    com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com/google/zxing/client/android/camera/CameraConfigurationUtils.class

    表示你添加了同一个类CameraConfigurationUtils.class两次

    检查您的 jar 文件。
    如果您有 libs/android-core-3.2.1.jar,您将添加两次相同的课程。
    这个类在jar里面,在library里面编译'com.journeyapps:zxing-android-embedded:3.2.0@aar'

    从 libs 文件夹中删除 jar 文件。

    【讨论】:

      【解决方案2】:

      重复条目:com/google/zxing/

      您添加了太多库。尝试一次删除一个,直到您的应用程序可以构建。

      首先从与 Zxing 相关的库中删除任何冲突的 Jar 文件

      Zxing核心不是必须的,内嵌的已经编译好了

      compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
      // compile 'com.google.zxing:core:3.2.0'
      

      Multidex / 更改您的 SDK 版本不会神奇地修复重叠的依赖项

      【讨论】:

        猜你喜欢
        • 2011-10-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-10-13
        • 1970-01-01
        • 2012-06-12
        相关资源
        最近更新 更多