Код плагина написан на kotlin 1.8.0, поэтому то же самое необходимо установить в вашем проекте Android для компиляция. Измените kotlin_version на 1.8.0 в файле android/build.gradle. ext.kotlin_version = '1.8.0'
Однако в последних версиях флаттера нет блока buildscript в файле build.gradle. Итак, посмотрев некоторое время, я обнаружил, что settings.gradle теперь включает в себя способ обновления версии Kotlin, что я и сделал.
При попытке запустить приложение я столкнулся со следующей ошибкой:
ОШИБКА: сборка не удалась с исключением.
Что пошло не так:
Не удалось выполнить задачу ':edge_detection:compileDebugKotlin'.
Ошибка при оценке свойства 'compilerOptions.jvmTarget' задачи ':edge_detection:compileDebugKotlin'.
Не удалось вычислить значение свойства 'jvmTarget'.
> Неизвестная цель Kotlin JVM: 21
Это это мой файл android/build.gradle:
Код: Выделить всё
plugins {
// ...
// Add the dependency for the Google services Gradle plugin
id 'com.google.gms.google-services' version '4.4.2' apply false
}
allprojects {
repositories {
google()
mavenCentral()
}
subprojects {
afterEvaluate { project ->
if (project.hasProperty('android')) {
project.android {
if (namespace == null) {
namespace project.group
}
}
}
}
}
}
rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(":app")
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
Код: Выделить всё
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.3.2" apply false
id "org.jetbrains.kotlin.android" version "1.8.0" apply false
id "com.google.gms.google-services" version "4.4.2" apply false
}
include ":app"
Код: Выделить всё
id "com.android.application"
id "kotlin-android"
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id "dev.flutter.flutter-gradle-plugin"
id 'com.google.gms.google-services'
}
android {
namespace = "com.example.new_flutter_demo"
compileSdk = flutter.compileSdkVersion
ndkVersion = "25.1.8937393"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.example.new_flutter_demo"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = 23
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 = "../.."
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:33.6.0')
}
Подробнее здесь: https://stackoverflow.com/questions/792 ... h-intellij