My goal is to write a library using Android Studio that can be distributed to 3rd party developers as either a JAR or AAR.
My library will have dependencies on other libraries.
When a 3rd party developer creates an app with a dependency on my library will my library’s dependencies by included in the 3rd party developers project?
I am seeing that this is not the case.
Here is my libraries app/build.gradle file:
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
def BOOLEAN = "boolean"
def TRUE = "true"
def FALSE = "false"
def IS_OFFLINE_MODE = "isOfflineMode"
def IS_ONLINE_PLUS_MODE = "isOnlinePlusMode"
publishNonDefault true
defaultConfig {
applicationId "com.djh.kelvin_android_api"
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors{
offline {
applicationId "com.djh.testlibrary.offline"
versionName "1.0-offline"
buildConfigField BOOLEAN, IS_OFFLINE_MODE, TRUE
}
online {
applicationId "com.djh.testlibrary.online"
versionName "1.0-online"
buildConfigField BOOLEAN, IS_OFFLINE_MODE, FALSE
buildConfigField BOOLEAN, IS_ONLINE_PLUS_MODE, FALSE
}
onlinePlus{
applicationId "com.djh.testlibrary.onlinePlus"
versionName "1.0-onlinePlus"
buildConfigField BOOLEAN, IS_OFFLINE_MODE, FALSE
buildConfigField BOOLEAN, IS_ONLINE_PLUS_MODE, TRUE
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.0.+'
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
compile 'org.apache.commons:commons-math3:3.3'
compile 'com.google.code.gson:gson:2.3'
}
When I include this library project into another app, I create a dependency like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
packagingOptions {
exclude 'AndroidManifest.xml'
exclude 'assets/databases/dillonDb.db'
exclude 'res/drawable-hdpi-v4/ic_launcher.png'
exclude 'res/drawable-mdpi-v4/ic_launcher.png'
exclude 'res/drawable-xhdpi-v4/ic_launcher.png'
exclude 'res/drawable-xxhdpi-v4/ic_launcher.png'
}
defaultConfig {
applicationId "com.djh.offlineaartest"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
}
//NOTE THIS SECTION HAS TO BE THERE FOR GRADLE TO FIND THE AAR FOR SOME REASON
repositories {
flatDir {
dirs 'libs'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.aar'])
compile(name:'app-offline-debug', ext:'aar')
}
Is this the correct behavior? Is there a way to achieve what I am trying to accomplish?
Thanks