简体   繁体   English

Gradle:下载包含aar-library的依赖项

[英]Gradle: download Dependencies of included aar-library

I wrote a library-project cameraBarcodeScanner that is built into an aar file. 我写了一个库项目cameraBarcodeScanner ,它内置在aar文件中。 This library has the following dependencies defined in its build.gradle: 此库在其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 finds the application and is able to build it. Gradle找到应用程序并能够构建它。 However, on runtime, android is not able to find the classes, that are located in zxing-android-embedded . 但是,在运行时,android无法找到位于zxing-android-embedded It seems to me, that gradle is not downloading the dependencies of the library-project. 在我看来,gradle没有下载库项目的依赖项。 I also tried: 我也尝试过:

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

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? 您将如何使用库并使gradle下载其依赖项?

Thanks in advance! 提前致谢!

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. aar文件不包含嵌套(或传递 )依赖项 ,并且没有描述库使用的依赖项的pom文件。

It means that, if you are importing a aar file using a flatDir repo you have to specify the dependencies also in your project . 这意味着,如果使用flatDir repo导入aar文件,则还必须在项目中指定依赖项

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. 您应该使用maven存储库 (您必须在私有或公共maven存储库中发布库),您将不会遇到相同的问题。
In this case, gradle downloads the dependencies using the pom file which will contains the dependencies list. 在这种情况下,gradle使用包含依赖项列表的pom文件下载依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM