简体   繁体   中英

Gradle import external android library

I am trying to cleany reference a library (android library project, not jar) in the gradle script of my android app but I encounter some difficulties :
The automatic Android Studio import script created this structure :

--- Main module
--- library1
--- library2

It compiles correctly but library1 & 2 are copies of the original libraries codebases. I would like to be able to refer to these library as relative paths in my build, something along compile '../library1' but I can't find any documentation on this kind of script where you don't have a common root.
Any pointer would be much appreciated.

in your Main module, add settings.gradle for setting up the path of libraries:

include 'library1'
include 'library2'

project(':library1').projectDir = new File('../library1')
project(':library2').projectDir = new File('../library2')

and include them in your build.gradle of Main module

dependencies {
    compile project(':library1')
    compile project(':library2')
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM