[英]Flutter Project Build Failure
FAILURE:構建失敗並出現異常。
其中:構建文件 '/Users/ VS Code Projects /zero_app/android/app/build.gradle' 行:26
出了什么問題:評估項目“:app”時出現問題。
未能應用插件“kotlin-android”。 名為“android”的擴展名不存在。 當前注冊的擴展名:[ext, googleServices, kotlin, kotlinTestRegistry]
使用 --stacktrace 選項運行以獲取堆棧跟蹤。 使用 --info 或 --debug 選項運行以獲得更多日志 output。 運行 --scan 以獲得完整的見解。
在 600 毫秒內構建失敗異常:Gradle 任務 assembleDebug 失敗,退出代碼 1 退出(sigterm)
構建.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'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 30
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 "com.scriptlk.zero_app"
minSdkVersion 21
targetSdkVersion 30
multiDexEnabled true
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 platform('com.google.firebase: firebase:firebase-bom:26.8.0')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
}
試試下面的代碼片段。
Android Studio 修改您的 build.gradle 添加應用插件:'kotlin-android' 上面應用插件:'com.android.application'。 只需將 Kotlin 線移到 Android 下方一位,Gradle 就會順利運行。 它應該看起來像這個例子:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.