Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include dependencies into .aar library?

I'm using Android Studio 1.4

I have a module in my project that's having next dependencies in build.gradle:

dependencies {
    provided fileTree(dir: 'libs', include: ['*.jar'])
    provided 'junit:junit:4.12'
    apply plugin: 'com.google.gms.google-services'
    provided 'org.apache.directory.studio:org.apache.commons.io:2.4'
    provided 'com.google.android.gms:play-services:8.1.0'
    provided 'com.fasterxml.jackson.core:jackson-databind:2.2.0'
    provided 'com.fasterxml.jackson.core:jackson-core:2.2.0'
    provided 'com.fasterxml.jackson.core:jackson-annotations:2.2.0'
}

After building the projectn and syncing gradle, I getting lib-release.aar at my module/build/ouputs/aar folder. Than I trying to File>New Module>Import JAR\AAR it. Then, after adding

compile project(':mylib-release')

I'm getting only my package without stated dependencies at "External Libraries" tree. How to enable autoinstall of these packages via only compilling my library?

like image 571
Vassily Avatar asked Oct 08 '15 21:10

Vassily


People also ask

How do I add a dependency to AAR?

Add your AAR or JAR as a dependency To use your Android library's code in another app module, proceed as follows: Navigate to File > Project Structure > Dependencies. In the Declared Dependencies tab, click and select Jar Dependency in the dropdown.

How do I add a dependency in Gradle?

Defining your dependency Now that Gradle knows which repository to look in, let's tell it what to look for. We do that within the dependencies section of the build script. Specify the co-ordinates, or in other words the group, artifactId, and version, within a string using a colon separator.

How do I check my AAR dependencies?

Ideally, there should be a pom file generated when you prepare AAR for deploy. You can find transitive dependencies of your AAR in that pom file.


1 Answers

Use

compile fileTree(dir: 'libs', include: ['*.jar'])

instead of

provided fileTree(dir: 'libs', include: ['*.jar'])
like image 180
ADattatrey Avatar answered Sep 20 '22 12:09

ADattatrey