2016-11-24 22 views
0

我已經嘗試過所有解決方案,這些解決方案在堆棧溢出和Google中都與我的問題有關。我厭倦了這個錯誤。如何解決錯誤:':app:transformClassesWithJarMergingForDebug'。?

我使用這在下面gradle這個文件添加掃描QR碼的lib,所以在我添加此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:[email protected]' 
    compile 'com.embarkmobile:zxing-android-integration:[email protected]' 
    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

會很感激一些EXPEC泰德解決方案也將解決許多相關的問題

在此先感謝。

+1

這絕不是您的問題的答案,但..如果問題出在'zxing'上,那麼您總是可以切換到例如代替'google.vision.barcode'。這是支持庫中提供的Google默認條形碼庫。大概[這篇文章](https://www.varvet.com/blog/android-qr-code-reader-made-easy/)會讓你立即用QR閱讀器運行! – Algar

+0

哦,我的天啊,最後我得到了這個問題的答覆,謝謝。!,但我可能知道你是否使用這個代碼和它的性能 – Raju

+0

實際上上面的lib也適用於我一個項目,但當我嘗試添加另一個項目拋出這個錯誤 – Raju

回答

0

最後我發現我的問題from this post經過漫長的一天回來的解決方案。而且我也更改了QR /條形碼掃描儀的庫。

問題:我在外部使用罐子名稱爲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' 
} 

,我已經改變了我的新的lib太ZXing Android Embedded高效QR /條形碼掃描器。

現在它的工作就像魅力。

0

問題:

我發現我不僅含有core.jar添加,而且編譯斑馬線相關的遠程倉庫,所以它導致上述錯誤。

解決方案:

該解決方案刪除core.jar添加文件,那麼它的確定。

+0

我不太確定**這是什麼**;它似乎既是一個無關的問題,也是無關問題的解決方案。你應該把它寫成一個新的問題(可能作爲參考鏈接到這個問題),然後回答你的解決方案。你可以找到更多關於自我回答問題的信息[** here **](https://stackoverflow.com/help/self-answer)。 –

+0

這不提供問題的答案。一旦你有足夠的[聲譽](https://stackoverflow.com/help/whats-reputation),你將可以[對任何帖子發表評論](https://stackoverflow.com/help/privileges/comment);相反,[提供不需要提問者澄清的答案](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-c​​an- I-DO-代替)。 - [來自評論](/ review/low-quality-posts/17234925) – MikeT