Gradle與插件版本的對(duì)應(yīng)關(guān)系

Android 成長(zhǎng)在于積累和分享

前言

每次更新完 Android Studio 大概都會(huì)遇到需要升級(jí)Gradle的問題。每次改完Gradle版本后,還要對(duì)應(yīng)改插件版本,這里記錄下對(duì)應(yīng)關(guān)系與官網(wǎng)地址。

Gradle 版本配置位置

可以在 Android Studio 的 File > Project Structure > Project 菜單中指定 Gradle 版本,也可以通過在 gradle/wrapper/gradle-wrapper.properties 文件中修改 Gradle 分發(fā)引用來指定。

  • File > Project Structure > Project
    image.png
  • gradle-wrapper.properties文件中修改distributionUrl字段

distributionUrl=https://services.gradle.org/distributions/gradle-7.3-bin.zip

Gradle 插件版本配置位置

project對(duì)應(yīng)的 build.gradle 文件中或者在 File > Project Structure > Project 中設(shè)置


buildscript {

    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

注意

使用 Android Gradle 插件 7.0 構(gòu)建應(yīng)用時(shí),現(xiàn)在需要 JDK 11 才能運(yùn)行 Gradle。Android Studio Arctic Fox 捆綁了 JDK 11,并將 Gradle 配置為默認(rèn)使用 JDK 11,這意味著大多數(shù) Android Studio 用戶不需要對(duì)項(xiàng)目進(jìn)行任何配置更改。

Gradle 對(duì)應(yīng)版本

Plugin version Required Gradle version
1.0.0 - 1.1.3 2.2.1 - 2.3
1.2.0 - 1.3.1 2.2.1 - 2.9
1.5.0 2.2.1 - 2.13
2.0.0 - 2.1.2 2.10 - 2.13
2.1.3 - 2.2.3 2.14.1 - 3.5
2.3.0+ 3.3+
3.0.0+ 4.1+
3.1.0+ 4.4+
3.2.0 - 3.2.1 4.6+
3.3.0 - 3.3.3 4.10.1+
3.4.0 - 3.4.3 5.1.1+
3.5.0 - 3.5.4 5.4.1+
3.6.0 - 3.6.4 5.6.4+
4.0.0+ 6.1.1+
4.1.0+ 6.5+
4.2.0+ 6.7.1+
7.0 7.0+

參考文獻(xiàn)

Android Gradle 插件版本說明(https://developer.android.google.cn/studio/releases/gradle-plugin)

最后編輯于
?著作權(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)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

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

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