问题描述
是的,我知道这听起来很少见,但是当 gradle 运行时,会在任务 ':app:checkDebugDuplicateClasses' 和 'com.google.zxing.*' 中给出重复依赖项。显然,一个 Flutter 包使用 com.github.leyan95:android-zxingLibrary:0.1.2-PRE
,另一个使用 com.google.zxing:core:3.3.3
,并且两者都有 com.google.zxing.BarcodeFormat
类。
输出如下:
FAILURE: Build Failed with an exception.
* What went wrong:
Execution Failed for task ':app:checkDebugDuplicateClasses'.
> 1 exception was raised by workers:
java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class com.google.zxing.BarcodeFormat found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.Binarizer found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.BinaryBitmap found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.ChecksumException found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.DecodeHintType found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.Dimension found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.EncodeHintType found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.FormatException found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.InvertedluminanceSource found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.luminanceSource found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.MultiFormatReader found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.MultiFormatWriter found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.MultiFormatWriter$1 found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.NotFoundException found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.PlanarYUVluminanceSource found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.RGBluminanceSource found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.Reader found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.ReaderException found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.Result found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.ResultMetadataType found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.ResultPoint found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.ResultPointCallback found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.Writer found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.WriterException found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.aztec.AztecDetectorResult found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.aztec.AztecReader found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.aztec.AztecWriter found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.aztec.decoder.Decoder found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.aztec.decoder.Decoder$1 found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.aztec.decoder.Decoder$Table found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.aztec.detector.Detector found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.aztec.detector.Detector$Point found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.aztec.encoder.AztecCode found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.aztec.encoder.BinaryShiftToken found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.aztec.encoder.Encoder found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.aztec.encoder.HighLevelEncoder found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)
Duplicate class com.google.zxing.aztec.encoder.HighLevelEncoder$1 found in modules jetified-android-zxingLibrary-0.1.2-PRE-runtime.jar (com.github.leyan95:android-zxingLibrary:0.1.2-PRE) and jetified-core-3.3.3.jar (com.google.zxing:core:3.3.3)...
(and so on with every class of the dependency com.google.zxing)
Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD Failed in 14s
Exception: Gradle task assembleDebug Failed with exit code 1
关于从哪里开始寻找解决方案的任何想法?
解决方法
我找到了解决方案,我唯一需要做的就是在gradle中添加下一行
configurations.all {
exclude group: 'com.google.zxing',module: 'core'
}
希望解决方案可以帮助其他人。