工程中要用到,挺实用的一个技巧
简单翻译下:
在工程的build.gradle 中
1.使用flatDir创建一个本地库
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
2. 添加依赖有两种方式
dependencies {
compile 'com.kevinpelgrims.library:library:1.0.0@aar'
}
必须使用 @aar
指定依赖的类型,但是有个麻烦的地方是每次需要更新版本号。
在最近的版本中支持下面的方式,(在android studio1.2中肯定支持,这个我验证过,其他早期版本没验证)
dependencies {
compile(name:'libraryfilename', ext:'aar')
}
这样不用每次更新版本号了,更容易使用。
PS:有时需要根据不同编译类型指定不同文件。可以用
debugCompile,releaseCompile代替compiledependencies {
debugCompile(name:'libraryfilename-debug', ext:'aar')
}releaseCompile(name:'libraryfilename-release', ext:'aar')
原文请看:
http://kevinpelgrims.com/blog/2014/05/18/reference-a-local-aar-in-your-android-project/