【问题标题】:android studio how to use library dependencies already added in library moduleandroid studio如何使用库模块中已经添加的库依赖项
【发布时间】:2015-08-13 01:10:46
【问题描述】:
--MyProject (module)
    --build.gradle
        dependencies {
            compile fileTree(include: ['*.jar'], dir: 'libs')
            compile 'com.android.support:appcompat-v7:22.2.1'
            compile project ':MyLib'
        }
--MyLib (module)
    --build.gradle
        dependencies {
            compile 'com.mcxiaoke.volley:library:1.0.16'
            compile 'com.google.code.gson:gson:2.3.1'
        }

在名为 MyLib 的库模块中,我添加了(例如)Gson 和 Volley 作为库。

我希望在MyProject 模块中使用GsonVolley api,而无需再次添加库作为依赖项,但我不能。当我在MyProject build.gradle 中添加GsonVolley 时,会导致错误:

多个dex文件定义

如何重用已添加到 MyLib 模块中的依赖项?如果这是不可能的,我该如何避免这个multiple dex files define 错误?我试过Android Studio Gradle Error: Multiple dex files define

dexOptions {
    preDexLibraries = false
}

但它没有帮助。

提前致谢。

【问题讨论】:

    标签: android android-studio build.gradle


    【解决方案1】:

    如果您希望在每个模块中使用 VolleyGson 库,则需要将这两个库作为依赖项添加到 bothbuild.gradle 文件 (@987654326 @ 和 MyLib)。

    至于multiple dex files define 错误,我会尝试看看这些潜在的解决方案:

    祝你好运!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-11
      • 2016-04-18
      • 2014-09-15
      • 2014-02-05
      • 2015-12-09
      • 2017-07-09
      • 1970-01-01
      • 2014-03-14
      相关资源
      最近更新 更多