Gradle技巧

  • 通过 --offline ,离线编译,免去检测的网络耗时
  • 通过 gradle --stop ,停止所有的gradle编译,包括IDE中的
  • 需要配置分离api、impl包可以参考 gradle-sample

引用关系

可以通过 ./gradlew dependencies 来查看最终的依赖关系。

如针对项目中的app module进行查看其引用关系: ./gradlew :app:dependencies 。

需要特别注意的是

都是对相通库同类型的引用,如都是 testCompile ,或都是 compile ,那么Gradle会自动选择最高版本的:

compile'cn.dreamtobe.filedownloader:filedownloader-okhttp3-connection:1.0.0'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.liulishuo.filedownloader:library:1.4.1'

对相同库不同类型的引用时,此时会发生冲突:

compile'cn.dreamtobe.filedownloader:filedownloader-okhttp3-connection:1.0.0'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
testCompile 'com.liulishuo.filedownloader:library:1.4.1'

这个时候我们就要根据需要exclude掉冲突的版本,如我们只需要引用 okhttp 3.6.0 版本与 filedownloader 1.4.1 :

compile('cn.dreamtobe.filedownloader:filedownloader-okhttp3-connection:1.0.0') {
    exclude group: 'cn.dreamtobe.filedownloader', module: 'library'
    exclude module: 'okhttp'
}
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.liulishuo.filedownloader:library:1.4.1'

testCompile 'com.liulishuo.filedownloader:library:1.4.1'
testCompile 'com.squareup.okhttp3:okhttp:3.6.0'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值