【问题标题】:Flutter Project Build FailureFlutter 项目构建失败
【发布时间】:2022-01-16 02:29:57
【问题描述】:

FAILURE:构建失败并出现异常。

  • 在哪里: 构建文件 '/Users/ VS Code Projects /zero_app/android/app/build.gradle' 行:26

  • 出了什么问题: 评估项目 ':app' 时出现问题。

未能应用插件“kotlin-android”。 名为“android”的扩展名不存在。当前注册的扩展名:[ext, googleServices, kotlin, kotlinTestRegistry]

  • 试试:

使用 --stacktrace 选项运行以获取堆栈跟踪。 使用 --info 或 --debug 选项运行以获得更多日志输出。 运行 --scan 以获得完整的见解。

在 600 毫秒内构建失败 异常:Gradle 任务 assembleDebug 失败,退出代码为 1 退出(sigterm)

Build.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 flutter gradle build build.gradle


    【解决方案1】:

    试试下面的代码 sn-p。

    Android Studio 修改了您的 build.gradle,添加了应用插件:“kotlin-android”,应用插件:“com.android.application”。只需将 Kotlin 行移到 Android 行下方,Gradle 就会顺利运行。它应该看起来像这个例子:

    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android'
    

    【讨论】:

    • 我试过这个。但我仍然遇到同样的问题。
    猜你喜欢
    • 2021-05-09
    • 2019-09-22
    • 2021-12-26
    • 2021-12-07
    • 2021-11-15
    • 2020-05-14
    • 1970-01-01
    • 2021-11-01
    • 2022-07-20
    相关资源
    最近更新 更多