【发布时间】:2019-12-27 15:21:27
【问题描述】:
【问题讨论】:
标签: android android-studio gradle build.gradle
【问题讨论】:
标签: android android-studio gradle build.gradle
不要将 gradle 与 Android Gradle 插件混淆。
classpath 'com.android.tools.build:gradle:5.6'
这是 Android Gradle 插件,5.6 不存在。
使用最新的稳定版本:
classpath 'com.android.tools.build:gradle:3.5.0'
Check the release notes 用于其他版本。
要更改 gradle 版本, 编辑文件 gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
official doc 中的更多信息。
【讨论】:
Gradle 插件版本目前没有 5.6 版。下面的链接列出了 Google Marvel 存储库中 Gradle 插件版本的所有最新版本。
https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google
我认为您的意思是您的 Gradle 包装器属性中的 distributionUrl 版本:
转到您的 gradle-wrapper.properties 文件并按要求完成:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6-all.zip
那么您的项目的 build.gradle 文件将如下所示:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript
{
repositories
{
google()
jcenter()
}
dependencies
{
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.2.0'
classpath 'com.android.tools.build:gradle:3.4.2'
}
}
allprojects {
repositories {
google()
maven { url 'https://maven.google.com' }
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
【讨论】: