I'd like to share my source code among different projects through aar. Current version of Android studio is able to generate aar files automatically for library module. But I have a few issues:
- How to output aar files to specific folder?
Currently the output is in build/outputs/aar folder. Can I move the files automatically once the compilation has been finished.
- The dependencies in library module is not inherited by app module. For example:
My library module (build.gradle):
apply plugin: 'com.android.library'
......
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.code.gson:gson:2.2.4'
}
My app module:
apply plugin: 'com.android.application'
repositories {
mavenCentral()
flatDir {
dirs 'myaarfolder'
}
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.company.appid"
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile(name:'mylib-release', ext:'aar')
}
I got an error something like:
Error:(3, 35) Error: Package com.google.gson.annotations not exist
I have to add compile 'com.google.code.gson:gson:2.2.4' in the dependency of my app module (build.gradle)
Any idea? Thanks