Guava库重复录入错误

Guava library duplicate entry error

我正在尝试使用来自 github 的 guava library in my application. But I am also using chromium_webview 项目。此 webview 项目包含 guava 库。

我收到以下错误:

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'. java.util.zip.ZipException: duplicate entry: com/google/common/annotations/GwtIncompatible.class

我已经查看了 and this 个答案,但似乎没有任何效果。

这是我模块的 build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "my.package.name"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }

    dexOptions {
        incremental true
        javaMaxHeapSize "2048M"
        jumboMode = true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile files('libs/svgAndroid2-3Jan2014.jar')
    compile project(':chromium_webview')
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.google.guava:guava:18.0'
}

我已经在 chromium_webview 项目上尝试过这样的排除方法:

compile (project(':chromium_webview')) {
    exclude group: 'com.google.guava', module: "guava_javalib.jar"
}

像这样:

compile (project(':chromium_webview')) {
    exclude module: "guava_javalib.jar"
}

我可以不再使用同一个库吗?
有没有办法为两个模块使用相同的库?

// ======================= 编辑:

就像提到的@petey 的评论一样,我尝试只从我的模块中删除 guava 库,但我的模块没有读取另一个模块中的库。

compile 'com.google.guava:guava:18.0'

那是我尝试删除的行。

任何想法将不胜感激。
谢谢!!

我确实解决了这个问题,忘了 post 它。

所以这里的问题是我在我的项目中使用 maven/gradle 依赖项,但是 chromium_webview 库使用实际的 JAR 文件作为库。

我修改了库以使用 maven/gradle 依赖项。 Android Studio 和 Gradle 为我完成了所有工作并排除了必要的 类。

因此请确保它们(库和您的模块)使用相同的方法。
compile 'com.google.guava:guava:18.0'

我真的希望这对某人有所帮助。
谢谢。