繁体   English   中英

Flutter 项目构建失败

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM