Android gradle 3.0帶來(lái)了編譯速度的大幅優(yōu)化,api也做了大幅調(diào)整

image.png
android gradle 3.0 需要Gradle版本 >= 4.1
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
變化
- 引用library時(shí)會(huì)自動(dòng)引用對(duì)應(yīng)的flavor,比如app的 debug variant 自動(dòng)依賴(lài) library的 debug variant。
- 引入flavor dimensions,不同flavor dimensions的配置可以互相覆蓋
- dependency compile,provided改成 api, implementation, compileOnly, runtimeOnly
| New Configuration | Deprecated configuration | Note |
|---|---|---|
| implementation | compile | 依賴(lài)是內(nèi)部實(shí)現(xiàn),依賴(lài)改變時(shí),只會(huì)編譯當(dāng)前模塊 |
| api | compile | 依賴(lài)是會(huì)導(dǎo)出為api,依賴(lài)改變時(shí),所有依賴(lài)它的外部模塊都要重新編譯 |
| compileOnly | provided | |
| runtimeOnly | apk |
4.library project 中的本地jar包,不再包含在aar中,而是通過(guò)transitive dependencies由app模塊依賴(lài)
5.默認(rèn)使用aapt2
- androidTestUtil 用來(lái)在instrumentation test運(yùn)行之前安裝apk,比如testbutler
dependencies {
androidTestUtil 'com.linkedin.testbutler:test-butler-app:1.3.0@apk'
...
}