番石榴库重复输入错误 [英] Guava library duplicate entry error

查看:124
本文介绍了番石榴库重复输入错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的应用程序中使用 guava 库.但是我还使用了来自github的 chromium_webview 项目.此Webview项目包含番石榴库.

I am trying to use guava library in my application. But I am also using chromium_webview project from github. This webview project contains guava library.

然后出现以下错误:

错误:任务执行失败 ':app:packageAllDebugClassesForMultiDex'. java.util.zip.ZipException: 重复输入:com/google/common/annotations/GwtIncompatible.class

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

我查看了答案已经,似乎没有任何作用.

I've looked at this and this answers already and nothing seems to work.

这是我模块的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项目上尝试过排除方法,如下所示:

I've tried the exclude method on the chromium_webview project like this:

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

并这样:

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

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

Can I not use the same library again?
Is there a way to use the same library for both modules?

//======================

// =======================

就像@petey的评论一样,我尝试仅从模块中删除guava库,而我的模块不读取其他模块中的库.

Like @petey's comment mentioned, I tried removing just the guava library from my module and my module doesn't read the library in another module.

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

这就是我尝试删除的行.

that's the line I tried removing.

任何想法都会受到赞赏.
谢谢!!

Any ideas will be really appreciated.
Thank you!!

推荐答案

我确实确实解决了此问题,但忘记发布了.

I actually did fix this problem, forgot to post it.

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

So the issue here was I was using maven/gradle dependency in my project BUT the chromium_webview library was using an actual JAR file as a library.

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

I modified the library to use the maven/gradle dependency. Android Studio and Gradle did all the work for me and excluded the necessary classes.

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

So make sure they both (library and your module) use the same method.
compile 'com.google.guava:guava:18.0'

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

I really hope this helps someone.
Thank you.

这篇关于番石榴库重复输入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆