I am creating an Android library having dependencies based on the following components.
- My library code
- layout and resources file
- Gradle dependencies to third parties.
First I think of creating .jar file for my library but then I figured out that laulyoit and resources files are not compiled with the jar. Then i decided to create AAR file. Please suggest if this one is right move or is there any other alternative?
Now the main problem I am stuck with gradle dependencies. We are creating a paid library that uses some third parties like google only available through Gradle. Now since I am creating an AAR file, there would be no Manifest.xml and Gradle file, how can I integrate the third parties with my own code. And We have the strict instructions that we must not tell the users of library to include that third parties to include. In simple words, we cannot let the users know what kind of third parties our library is using. So is there any way I can create an AAR file that also have the gradle dependencies pre-compiled with this without revealing the user what services we are using?
Update 1
Here is my build.gradle for Library
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g" // 2g should be also OK
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services-vision:10.2.1'
testCompile 'junit:junit:4.12'
}
After the I am moving my .aar file to local maven and creating then using the output file in my application Project. Here is the gradle for same.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.jarvis.myapplication"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile('com.company:mylibrary:1.0@aar')
{
transitive = true
}
compile 'com.android.support:appcompat-v7:25.3.0'
testCompile 'junit:junit:4.12'
}