In my case I have some depencies in my library and when I create an aar
from it I failed, because of missed depencies, so my solution is to add all depencies from my lib with an arr
file.
So my project level build.gradle
looks so:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
mavenCentral()
//add it to be able to add depency to aar-files from libs folder in build.gradle(yoursAppModule)
flatDir {
dirs 'libs'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(modile app)
so:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.sampleapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//your project depencies
...
//add lib via aar-depency
compile(name: 'aarLibFileNameHere', ext: 'aar')
//add all its internal depencies, as arr don't have it
...
}
and library build.gradle
:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
//here goes library projects dependencies, which you must include
//in yours build.gradle(modile app) too
...
}
No comments:
Post a Comment