admin管理员组

文章数量:1308812

I recently installed Flutter, create first project, and try to run it in my phone devices with USB debugging. I execute command flutter build apk and flutter run, but it failed and show this error:

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\New\Flutter\flutter-project\graphstudio\android\app\build.gradle' line: 3

* What went wrong:
An exception occurred applying plugin request [id: '.jetbrains.kotlin.android']
> Failed to apply plugin '.jetbrains.kotlin.android'.
      > Could not initialize class .jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSetKt

* 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 .

BUILD FAILED in 1s
Running Gradle task 'assembleRelease'...                         2,015ms
Gradle task assembleRelease failed with exit code 1

This is some of my flutter code:

build.gradle (project level)

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
}

build.gradle (app level)

plugins {
    id "com.android.application"
    id ".jetbrains.kotlin.android"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
}

android {
    namespace = "com.graphci.graphstudio"
    compileSdk = flutterpileSdkVersion
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (.html).
        applicationId = "com.graphci.graphstudio"
        // You can update the following values to match your application needs.
        // For more information, see: /to/review-gradle-config.
        minSdk = flutter.minSdkVersion
        targetSdk = flutter.targetSdkVersion
        versionCode = flutter.versionCode
        versionName = flutter.versionName
    }

    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 = "../.."
}

I think the problem is in the compatibility or version of Kotlin, Gradle, or others, or there's anything setup that not configured yet

本文标签: