Android Studio Gradle Dependencies

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值