从编译排除的.jar Android Studio中与摇篮 [英] Exclude .jar from compile in Android Studio with Gradle

查看:188
本文介绍了从编译排除的.jar Android Studio中与摇篮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在该文件的build.gradle这样的事情。

I currently have something like this in the build.gradle file.

dependencies {
    compile 'com.android.support:support-v4:13.0.+'
    compile ('com.xxx:xxx-commons:1.+') {

    }
}

有一个问题就出现了,因为这两个JUnit和hamcrest核心是在com.xxx:xxx Maven仓库present,创造这样的错误:

A problem arises since both jUnit and hamcrest-core are present in the com.xxx:xxx maven repository, creating an error like this:

Gradle: Origin 1: /Users/yyy/.gradle/caches/artifacts-26/filestore/junit/junit/4.11/jar/4e031bb61df09069aeb2bffb4019e7a5034a4ee0/junit-4.11.jar
Gradle: Origin 2: /Users/yyy/.gradle/caches/artifacts-26/filestore/org.hamcrest/hamcrest-core/1.3/jar/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar

Gradle: Execution failed for task ':android:packageDebug'.
> Duplicate files copied in APK LICENSE.txt
File 1: /Users/yyy/.gradle/caches/artifacts-26/filestore/junit/junit/4.11/jar/4e031bb61df09069aeb2bffb4019e7a5034a4ee0/junit-4.11.jar
File 2: /Users/yyy/.gradle/caches/artifacts-26/filestore/junit/junit/4.11/jar/4e031bb61df09069aeb2bffb4019e7a5034a4ee0/junit-4.11.jar

由于JUnit的实际上包括hamcrest库,这些天有没有办法真正排除罐子是:hamcrest核-1.3.jar
或排除所有.txt文件,或从Maven仓库排除的JUnit都在一起(它不使用)。

Since jUnit actually includes the hamcrest library these days is there a way to actually exclude the jar that is: hamcrest-core-1.3.jar Or exclude all .txt files, or exclude jUnit all together from the maven repository (it's not used).

任何其他的想法,可能是有益的?

Any other ideas that could be helpful?

推荐答案

是的,你可以exclude传递依赖的:

在你的情况,这将是:

dependencies {
    compile 'com.android.support:support-v4:13.0.+'
    compile ("com.xxx:xxx-commons:1.+") {
        exclude group: 'junit', module: 'junit'
    }
}

configurations {
    all*.exclude group: 'junit', module: 'junit'
}

这篇关于从编译排除的.jar Android Studio中与摇篮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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