diff --git a/packages/firebase_analytics/firebase_analytics/android/build.gradle b/packages/firebase_analytics/firebase_analytics/android/build.gradle index 183ea4605c04..32a3040ee715 100755 --- a/packages/firebase_analytics/firebase_analytics/android/build.gradle +++ b/packages/firebase_analytics/firebase_analytics/android/build.gradle @@ -5,7 +5,7 @@ apply plugin: 'com.android.library' apply from: file("local-config.gradle") buildscript { - ext.kotlin_version = "1.8.22" + ext.kotlin_version = "2.2.20" repositories { google() mavenCentral() @@ -24,14 +24,24 @@ rootProject.allprojects { } } -apply plugin: 'com.android.library' - // AGP 9+ has built-in Kotlin support; older versions need the plugin explicitly. def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int -if (agpMajor < 9) { +def builtInKotlin = providers.gradleProperty("android.builtInKotlin") + .map { it.toBoolean() } + .orElse(agpMajor >= 9) + .get() +if (agpMajor < 9 || !builtInKotlin) { apply plugin: 'kotlin-android' } +plugins.withId("org.jetbrains.kotlin.android") { + kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 + } + } +} + def firebaseCoreProject = findProject(':firebase_core') if (firebaseCoreProject == null) { throw new GradleException('Could not find the firebase_core FlutterFire plugin, have you added it as a dependency in your pubspec?') @@ -58,12 +68,6 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - if (agpMajor < 9) { - kotlinOptions { - jvmTarget = project.ext.javaVersion - } - } - compileOptions { sourceCompatibility project.ext.javaVersion targetCompatibility project.ext.javaVersion