Android Studio 中 gradle 的為什麼有兩個版本號
阿新 • • 發佈:2018-12-18
情景再現
最近開啟Android Studio說要更新專案Gradle版本至4.6,結果build.gradle裡面是這樣的:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
還是3.2.0,結果去file–>project structure看到已經是4.6了 gradle-wrapper.properties檔案也是4.6
#Tue Oct 30 20:01:43 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all. zip
原因
gradle 外掛版本號
其實這個 classpath ‘com.android.tools.build:gradle:3.1.2’ 指的是 gradle 外掛的版本號,而不是 gradle 的版本號。
不過 gradle 外掛的版本號和 gradle 的版本號又是有關聯的,關係如下:
外掛版本號 | 需要的 Gradle 版本號 |
---|---|
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+ |
2.3.0+ | 3.3+ |
3.0.0+ | 4.1+ |
3.1.0+ | 4.4+ |