Gradle:下载包含的arar库的依赖项 [英] Gradle: download Dependencies of included aar-library

查看:96
本文介绍了Gradle:下载包含的arar库的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个库项目cameraBarcodeScanner,该项目内置在aar文件中.该库在build.gradle中定义了以下依赖项:

I wrote a library-project cameraBarcodeScanner that is built into an aar file. This library has the following dependencies defined in its build.gradle:

dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
 testCompile 'junit:junit:4.12'
 compile 'com.android.support:appcompat-v7:23.1.0'
 compile 'com.google.zxing:core:3.2.1'
 compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
}

我正在像这样的测试应用程序中使用该库:

I'm using the library in a test-application like so:

dependencies {
 compile(name: 'cameraBarcodeScanner-release', ext: 'aar')
}

Gradle可以找到该应用程序并能够对其进行构建.但是,在运行时,android无法找到位于zxing-android-embedded中的类.在我看来,gradle并没有下载library-project的依赖项. 我也尝试过:

Gradle finds the application and is able to build it. However, on runtime, android is not able to find the classes, that are located in zxing-android-embedded. It seems to me, that gradle is not downloading the dependencies of the library-project. I also tried:

dependencies {
 compile(name: 'cameraBarcodeScanner-release', ext: 'aar'){
  transitive = true
}

但这也无济于事.我是否必须以某种方式公开库的依赖关系?您将如何使用库并使gradle下载其依赖项?

But this didn't help either. Do I have to expose the library's dependencies in some way? How would you use a library and make gradle download its dependencies?

提前谢谢!

推荐答案

aar 文件不包含嵌套的(或

The aar file doesn't contain the nested (or transitive) dependencies and doesn't have a pom file which describes the dependencies used by the library.

这意味着,如果要使用flatDir存储库导入aar文件,则还必须在项目中指定依赖项.

It means that, if you are importing a aar file using a flatDir repo you have to specify the dependencies also in your project.

您应该使用 Maven存储库(您必须在私有或公共Maven存储库中发布库),您不会遇到相同的问题.
在这种情况下,gradle使用pom文件下载依赖项,该文件将包含依赖项列表.

You should use a maven repository (you have to publish the library in a private or public maven repo), you will not have the same issue.
In this case, gradle downloads the dependencies using the pom file which will contains the dependencies list.

这篇关于Gradle:下载包含的arar库的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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