FAILURE:构建失败并出现异常。
地点: 构建文件“C:\Users\ASUS\Documents yp ndroid uild.gradle”行:7
出了什么问题: 评估根项目“android”时出现问题。
在 org.gradle.api.internal.artifacts.dsl.dependency.DefaultDependencyHandler 类型的对象上找不到参数 [com.google.gms:google-services:4.4.1] 的方法 classpath()。
您可以将此代码的兼容版本添加到 android/build.gradle 文件的顶部。我的就是这样工作的。
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:8.1.0'
classpath 'com.google.gms:google-services:4.4.2'
classpath 'com.google.firebase:firebase-crashlytics-gradle:3.0.2'
}
}
plugins{
id "com.google.gms.google-services" version '4.4.2' apply false
id ("com.google.firebase.crashlytics") version '3.0.2' apply false
}
settings.gradle也是这样
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.1.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
id 'com.google.gms.google-services' version '4.4.2' apply false
}
include ":app"