我创建一个Android库(称为MyLib中),其依赖于对行家回购可用的其他文库(如GSON,改型,等等)。如何指定aar库中的依赖关系?
MyLib
|
|-- Retrofit
|-- Gson
|-- ...
MyLib打包成aar
文件。
的目标是不指定第二时间的依赖关系MyLib中用途发布其可被包括到一个Android应用程序(称为MyApp的)的AAR库。
MyApp
|
|-- MyLib
| |-- Retrofit
| |-- gson
| |-- ...
这是我的build.gradle文件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'
}
现在,如果我想建立和运行MyApp的无依赖的问题,我不得不使用下面的生成.gradle for MyApp(如果我没有指定翻新和gson作为deps,运行时ex因为没有可用的代价,因此抛出了ception)。
dependencies {
compile('[email protected]')
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.google.code.gson:gson:2.3.1'
}
我不想MyApp的被内部MyLib中使用的依赖关系指定,我应该怎么写我的build.gradle文件?预先
如果MyLib是本地的,你应该使用compile project(':MyLib') –
是的,MyLib是本地的,但是打包成aar。 MyLib和MyApp不在同一个项目中。这是两个不同的项目。 – reevolt
你总是可以参考projetc之外的另一个文件夹 –