Android Studio Gradle Dependencies
一、依赖配置
1. 远程库依赖(Library Dependency)
指定远程仓:
repositories {
mavenCentral()
}
配置编译依赖:
compile 'com.package.name:project_name:version'
如:compile 'com.xxx.xxx:project_name:1.3.1'
2. 文件依赖
指定后缀方式:
compile fileTree(dir: "libs', include: ['*.jar', "*.xxx"])
指定jar路径方式:
compile files('../mylibs/xxx.jar')
aar文件依赖:
依赖目录与文件
repositories {
flatDir{
dirs 'libs'
}
}
compile(name:'aar_file_name',ext:'aar')
3. 项目依赖
Android Studio的aar文件可以打包资源,不建议使用这种依赖。
compile project(':AnotherModule')
二、依赖类型
1. Compile
会将依赖编译并打包到最终的apk文件中。
2. Provider
依赖只参与编译,不会打包到apk中。
3. APK
依赖仅打包到apk中,不参与编译。
4. Test compile
依赖仅会在编译单元测试代码时被编译并打包到最终apk中。
5. Debug compile
依赖仅会在编译Debug版本时被编译并打包到最终apk中。
6. Release compile
依赖仅会在编译Release版本时被编译并打包到最终apk中。
参考链接:
http://www.94cto.com/index/Article/content/id/75315.html
http://www.cnblogs.com/kangyi/p/4449857.html