How to include JAR dependency into an AAR library
By default, AAR does not include any dependencies. Solution mentioned by @Hector should work for gradle plugin < 3.0. For Gradle plugin 3.0+, try custom config as mentioned here.
android { ... }
// Add a new configuration to hold your dependencies
configurations {
myConfig
}
dependencies {
....
myConfig 'com.android.support:appcompat-v7:26.1.0'
myConfig 'com.android.support:support-v4:26.1.0'
...
}
task copyLibs(type: Copy) {
from configurations.myConfig
into "libs"
}
You can add this task:
task copyLibs(type: Copy) {
from configurations.compile
into 'libs'
}
Dependencies will be downloaded from your Nexus, but when you need package the library, execute this task first and jar
files will be copied and included inside final aar
.