android gradle 3.0 學(xué)習(xí)筆記

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'
    }
}

變化

  1. 引用library時(shí)會(huì)自動(dòng)引用對(duì)應(yīng)的flavor,比如app的 debug variant 自動(dòng)依賴(lài) library的 debug variant。
  2. 引入flavor dimensions,不同flavor dimensions的配置可以互相覆蓋
  3. 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

  1. androidTestUtil 用來(lái)在instrumentation test運(yùn)行之前安裝apk,比如testbutler
dependencies {
  androidTestUtil 'com.linkedin.testbutler:test-butler-app:1.3.0@apk'
  ...
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容