Gradle: download Dependencies of the included aar library

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

 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 use the library in a test application as follows:

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

Gradle finds the application and can build it. However, at run time, android cannot find classes located in zxing-android-embedded . It seems to me that gradle does not load library project dependencies. I also tried:

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

But that didn't help either. Should I somehow identify library dependencies? How can you use the library and make gradle load your dependencies?

Thanks in advance!

+7
android android-gradle gradle aar gradle-dependencies
source share
1 answer

The aar file does not contain nested (or transitive ) dependencies and does not have a pom file that describes the dependencies used by the library.

This means that if you import the aar file using flatDir repo , you must specify the dependencies in your project as well .

You should use the maven repository (you must publish the library in a private or public maven repository), you will not have the same problem.
In this case, gradle loads the dependencies using the pom file, which will contain a list of dependencies.

+6
source share

All Articles