如何解决错误:':app:transformClassesWithJarMergingForDebug'。?

时间:2016-11-24 14:06:37

标签: android-studio plugins runtime-error qr-code

我已经尝试了所有解决方案,这些都与我的问题在堆栈溢出和谷歌相关。我厌倦了这个错误。

使用lib扫描下面的gradle文件中添加的qr代码,所以在我添加这个lib时只会出现以下错误

这是我的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.inspirenetz.app.inpartner"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }

    testOptions {
        unitTests.returnDefaultValues = true
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    testCompile 'org.json:json:20140107'
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:design:23.1.0'
    compile 'com.android.support:support-v4:23.1.0'
    compile 'com.github.satyan:sugar:1.4'
    compile 'com.google.code.gson:gson:2.4'
    compile 'com.fasterxml.jackson.core:jackson-core:2.4.1'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.1'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.4.1'
    compile group: 'cz.msebera.android' , name: 'httpclient', version: '4.4.1.1'

    compile 'com.embarkmobile:zxing-android-minimal:2.0.0@aar'
    compile 'com.embarkmobile:zxing-android-integration:2.0.0@aar'
    compile 'com.google.zxing:core:3.2.1'

    // Avoid the 64K limit, Multidex support for Android 5.0 and higher
    compile 'com.android.support:multidex:1.0.1'

    compile files('libs/mswiperAPIVer2.0.jar')

    repositories { mavenCentral()
        maven { url "https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/" }
    }

}

这里错误杀了我

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
  

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

非常感谢一些预期的解决方案也将解决许多相关问题

提前致谢。

2 个答案:

答案 0 :(得分:0)

最后,经过漫长的几天后,我找到了问题from this post 的解决方案。我也更改了QR /条形码扫描器的lib。

问题:我使用jar外部名称为core.jar。因此,AztecDetectorResult.class已经包含在core.jar和我的扫描程序lib依赖项core-3.2.1中。所以它会抛出重复的输入错误,如下所示。

com.android.build.api.transform.TransformException: 
java.util.zip.ZipException: duplicate entry: com/google/zxing/aztec/AztecDetectorResult.class

解决方案:我尝试将其从core.jar中排除,如下所示。

configurations{
    all*.exclude module: 'core'
}

我已经更改了我的新lib ZXing Android Embedded以获得有效的QR /条形码扫描器。

现在它的工作就像魅力一样。!

答案 1 :(得分:0)

<强>问题:

我发现我不仅包含core.jar,而且还编译zxing相关的远程存储库,因此导致上述错误。

解决方案:

解决方案是删除core.jar文件,然后就可以了。