android - 如何使用组、名称、版本、类型的格式在 build.gradle 中添加 @jar 类型的依赖项?

标签 android maven gradle android-studio

依赖的pom.xml用<packaging>apk</packaging>描述,这在编译中是行不通的。 所以我排除了依赖树中的模块并重新包含 compile 'package:artifactId:versionName@jar' 这确实有效,但是group:'groupName',name:'artifactId',version:'versionName',type:'type'的相应格式是什么? ? 我试过 type:'jar'这没有用。 我是否必须先排除依赖树中的依赖,然后再重新包含它?或者我可以修改父依赖的描述?

父依赖:

compile (group:'parentGroupId',name:'parentModuleName',version:'parentVersion'){
    exclude group:'excludeGroupId',module:'excludeModuleName'
}

compile 'excludeGroupId:excludeModuleName:excludeVersion@jar'

我试过了

compile (group:'parentGroupId',name:'parentModuleName',version:'parentVersion'){
    exclude group:'excludeGroupId',module:'excludeModuleName'
}

compile (group:'excludeGroupId',name:'excludeModuleName',version:'excludeVersion',type:'jar')

上面的没用

最佳答案

基于 http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.dsl.DependencyHandler.html 上的文档这看起来像是指定这种依赖关系的正确方法:

compile (group:'excludeGroupId',name:'excludeModuleName',version:'excludeVersion') {
    artifact {
        name = 'excludeModuleName'
        type = 'jar'
    }
}

请注意,artifact 中的冗余 name 规范是必需的——如果没有它,您将得到一个 NullPointerException

关于android - 如何使用组、名称、版本、类型的格式在 build.gradle 中添加 @jar 类型的依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25305177/

相关文章:

android - gridview 的样式自定义适配器

java - 声明 'FLAG_ACTIVITY_NO_ANIMATION' 后出现 NullPointerException 警告

maven - 为什么我无法解决 GeoTools maven quickstart 的依赖关系?

android - 无法构建项目

kotlin - 如何使用Gradle Kotlin DSL向所有 jar 添加前缀

android - Gradle 3.0.0-alpha1 与 kotlin-android 插件 1.1.2-3 不兼容?

android - 是否可以将类的静态对象存储在共享首选项中?

maven - Artifactory 不删除唯一快照

java - 在 Netbeans 中找不到 Maven

firebase - 无法解析 com.google.firebase :firebase-messaging:[10. 2.1、12.1.0)