Android Gradle - Buildings library module generates unexpected .aar
I am currently working on creating a multi-module project with the following structure:
Project Root
|- app/
|- src/
|- build.gradle
|- lib
|- src/
|- build.gradle
|- build.gradle
|- gradle.properties
|- settings.gradle
While the library module is working as expected, I get the following build error for the application module:
A problem was found with the configuration of task ':app:prepareProjectRootLib10Library'.
> File 'C:\projects\Project Root\lib\build\outputs\aar\lib-1.0.aar' specified for property 'bundle' does not exist.
As far as my build script goes, I don't think there is anything wrong with my build scripts. At the same time, when I search to generate .aar
libraries for my project, instead I find a file instead lib-1.0-SNAPSHOT.aar
, which explains the problem. While manually renaming this file to match what the build script expects is fixing the problem, I need a solution that requires manual work. Is there a way to change the construction of the script so that the application module can get the library project files it needs?
If it helps, below app/build.gradle
:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
minSdkVersion 16
targetSdkVersion 20
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
java.srcDirs = ['src/main/java']
resources.srcDirs = ['src/main/resources']
res.srcDirs = ['src/res']
assets.srcDirs = ['src/assets']
}
androidTest {
java.srcDirs = ['src/androidTest/java']
resources.srcDirs = ['src/androidTest/resources']
res.srcDirs = ['src/res']
assets.srcDirs = ['src/assets']
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile project(':lib')
compile 'com.android.support:support-v4:20.0.0'
}
And this lib/build.gradle
:
apply plugin: 'com.android.library'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
minSdkVersion 16
targetSdkVersion 20
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
java.srcDirs = ['src/main/java']
resources.srcDirs = ['src/main/resources']
res.srcDirs = ['src/res']
assets.srcDirs = ['src/assets']
}
androidTest {
java.srcDirs = ['src/androidTest/java']
resources.srcDirs = ['src/androidTest/resources']
res.srcDirs = ['src/res']
assets.srcDirs = ['src/assets']
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile 'com.android.support:support-v4:20.0.0'
}
source to share
No one has answered this question yet
Check out similar questions: