How do i add an external library and nested external libraries to an android project?
My project structure (Not allowed to change)
- Apps/
- App1/
- build.gradle
- settings.gradle
- libraries/
- library1/
- build.grade
- settings.gradle
- library2/
- build.grade
- settings.gradle
- library3/
- build.grade
- settings.gradle
- library4/
- build.grade
- settings.gradle
- library1/
- App1/
App1
App1/build.gradle
buildscript {
...
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':..:libraries:library1')
compile project(':..:libraries:library2')
compile project(':..:libraries:library3')
compile project(':..:libraries:library4')
}
android {
...
}
App1 does not directly depend on library3
or library4
, however, it will complain if i don't include them in the dependencies in the build.gradle
file and the settings.gradle
file. So, i have them included just to stop it from complaining.
App1/settings.gradle
include ':'
include '..:libraries:library1'
include '..:libraries:library2'
include '..:libraries:library3'
include '..:libraries:library4'
library1
library1/build.gradle
buildscript {
...
}
apply plugin: 'android-library'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':..:library3')
compile project(':..:library4')
}
android {
...
}
library1/settings.gradle
include ':'
include '..:library3'
include '..:library4'
library2..4
library2..4/build.gradle
buildscript {
...
}
apply plugin: 'android-library'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
...
}
library2..4/settings.gradle
include ':'
When trying to gradlew clean build
on App1
i get the following error:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/user/projects/branches/branch1/Apps/libraries/library1/build.gradle' line: 15
* What went wrong:
A problem occurred evaluating project ':..:library:library1'.
> Project with path ':..:library3' could not be found in project ':..:library:library1'.
Line 15 is compile project(':..:library3')
in the library1/build.gradle
file.
How do i add an external library and nested external libraries to an android project?