您正在使用 apply script 方法强制应用 Flutter 的 app_plugin_loader Gradle 插件,该方法已弃用,并将在未来版本中删除。迁移到使用声明性插件块应用 Gradle 插件:https://flutter.dev/go/flutter-gradle-plugin-apply
您正在使用 apply script 方法强制应用 Flutter 的主 Gradle 插件,该方法已弃用并将在未来版本中删除。迁移到使用声明性插件块应用 Gradle 插件:https://flutter.dev/go/flutter-gradle-plugin-apply
我面临着如何克服这个警告
我已更新我的 gradle 设置并将我的 build.gradle 依赖项数据移至 settings.gradle
要解决此警告,您必须更改 build.gradle 和 settings.gradel 文件
///旧设置.gradle
include ':app'
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
新设置.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
}
settings.ext.flutterSdkPath = flutterSdkPath()
includeBuild("${settings.ext.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 "7.1.2" apply false
id "org.jetbrains.kotlin.android" version "1.8.0" apply false
id "com.google.gms.google-services" version "4.3.13" apply false
// id "com.google.firebase:firebase-bom" version "31.0.1" apply false
}
include ":app"
旧的 android/build.gradle
buildscript {
ext.kotlin_version = '1.8.0'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.13'
}
}
新的 android/build.gradle
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
从 app/build.gradle 中删除它
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
将其添加到 app/build.gradle
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
id "com.google.gms.google-services"
}