【问题标题】:Use local lib instead of nexus one使用本地库而不是 nexus 一
【发布时间】:2015-06-02 12:11:15
【问题描述】:

使用 gradle 构建 Android 项目。库 com.test.x 是从 nexus 获取的。在开发过程中,我想用我放在 libs 文件夹中的一个来覆盖 nexus 库。

在 gradle 构建文件中:

compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.test:com.test.x:version'

我得到的错误:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.test.dex.DexException: Multiple dex files define Lcom/test/x/...;

似乎有问题,因为lib现在在项目中有两次?如何解决?还是有其他办法解决这个问题?

【问题讨论】:

    标签: android gradle android-gradle-plugin


    【解决方案1】:

    您可以将debugCompile 用于本地副本,将releaseCompile 用于工件,以将依赖关系与构建类型联系起来。

    例如,我在我的许多 CWAC 库中都这样做,但在我的情况下,它是我的演示应用程序所依赖的库模块,而不是 JAR:

    dependencies {
        debugCompile project(':provider')
        releaseCompile 'com.commonsware.cwac:provider:0.2.+'
    }
    

    根据构建类型(debugrelease),只有其中一个依赖项将用于构建。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-22
      • 1970-01-01
      • 1970-01-01
      • 2012-11-02
      • 2015-08-28
      • 2014-07-12
      • 2011-04-15
      • 2023-04-06
      相关资源
      最近更新 更多