I created an Android library (called MyLib) which depends on other library available on maven repo (like gson, retrofit, etc.).
MyLib
|
|-- Retrofit
|-- Gson
|-- ...
MyLib is packaged to an aar
file.
The goal is to publish an aar library which can be included into an Android app (called MyApp) without specifying a second time the dependencies that MyLib uses.
MyApp
|
|-- MyLib
| |-- Retrofit
| |-- gson
| |-- ...
This is my build.gradle file for MyLib
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.google.code.gson:gson:2.3.1'
}
Now, if I want to build and run MyApp without dependency issue, I had to use the following build.gradle for MyApp (if I don't specify retrofit and gson as deps, a runtime exception is thrown because the deps are not available).
dependencies {
compile('MyLib@aar')
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.google.code.gson:gson:2.3.1'
}
I don't want to specify in MyApp the dependencies that are used inside MyLib, How should I write my build.gradle files?
Thansk in advance
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…