- 通过
--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'