Flutter 无法获取 org.gradle.api.Project 类型的项目 ':app' 的未知属性'plugin'。错误



运行我的Flutter应用程序时出现此错误:

Launching libmain.dart on Android SDK built for x86 in debug mode...
FAILURE: Build failed with an exception.
* Where:
Build file 'C:DosyalarYaz�l�mFlutterSimto-To-Do-Listsimto_todolistandroidappbuild.gradle' line: 23
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not get unknown property 'plugin' for project ':app' of type org.gradle.api.Project.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BU�LD FAILED in 1s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

我开始得到这个错误后,我改变了我的Flutter项目的位置。

错误中提到的androidappbuild.gradle代码:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin 'com.android.application' // line 23
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "io.simto.todolist.app"
minSdkVersion 23
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation platform('com.google.firebase:firebase-bom:29.2.1')
}

这是我第一次遇到这个问题。为什么会出现这个错误?我怎么解它?提前感谢您的帮助。

美好的一天。

第23行,apply plugin之后缺少:。要解决这个问题,将第23行更改为:

apply plugin: 'com.android.application'

相关内容

  • 没有找到相关文章

最新更新