在這裏查看插件和 gradle 版本的對應關係:
- https://developer.android.google.cn/studio/releases/gradle-plugin
- https://devloper.android.com/studio/releases/gradle-plugin
然後注意 build.gradle
裏面的 classpath
應該這樣寫,Android Studio 會自動下載新版本。
buildscript {
repositories {
// Gradle 4.1 and higher include support for Google's Maven repo using
// the google() method. And you need to include this repo to download
// Android Gradle plugin 3.0.0 or higher.
google() // 注意這一行!!!
mavenCentral() // 這行也是需要的!!
...
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0' // 修改這個版本
}
}
然後修改 gradle-wrapper.properties
文件,把
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
修改爲對應的最新 gradle 版本 gradle-5.1.1-all.zip
本地路徑爲
C:\Program Files\Android\Android Studio\gradle\m2repository\com\android\tools\build\gradle
以下方法已過時
訪問:http://jcenter.bintray.com/com/android/tools/build/builder/
查看最新版本是多少。