How to solve Error: ':app:transformClassesWithJarMergingForDebug'.?
How to solve Error: ':app:transformClassesWithJarMergingForDebug'.?
我已经尝试了所有的解决方案,这些解决方案都与我在堆栈溢出中的问题有关,google 也是如此。我受够了这个错误。
我正在使用 lib 来扫描添加到下面 gradle 文件中的二维码,所以在我添加这个 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: duplicate entry: com/google/zxing/aztec/AztecDetectorResult.class
非常感谢一些预期的解决方案也能解决许多相关问题
提前致谢!
经过漫长的日子,我终于找到了问题的解决方案 from this post 。我也更改了 QR/Bar 代码扫描器的库。
问题: 我使用 jar 外部名称为 core.jar
。因此,AztecDetectorResult.class
已经包含在 core.jar
和我的扫描仪库依赖项 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'
}
我也更改了我的新库 ZXing Android Embedded 以实现高效的 QR/Bar 代码扫描器。
现在它像魅力一样工作!
问题:
我发现我不仅包含core.jar,还编译了zxing相关的远程仓库,所以导致上面的错误。
解法:
解决方法是删除core.jar文件就可以了。
我已经尝试了所有的解决方案,这些解决方案都与我在堆栈溢出中的问题有关,google 也是如此。我受够了这个错误。
我正在使用 lib 来扫描添加到下面 gradle 文件中的二维码,所以在我添加这个 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: duplicate entry: com/google/zxing/aztec/AztecDetectorResult.class
非常感谢一些预期的解决方案也能解决许多相关问题
提前致谢!
经过漫长的日子,我终于找到了问题的解决方案 from this post 。我也更改了 QR/Bar 代码扫描器的库。
问题: 我使用 jar 外部名称为 core.jar
。因此,AztecDetectorResult.class
已经包含在 core.jar
和我的扫描仪库依赖项 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'
}
我也更改了我的新库 ZXing Android Embedded 以实现高效的 QR/Bar 代码扫描器。
现在它像魅力一样工作!
问题:
我发现我不仅包含core.jar,还编译了zxing相关的远程仓库,所以导致上面的错误。
解法:
解决方法是删除core.jar文件就可以了。