diff --git a/packages/cloud_functions/cloud_functions/android/build.gradle b/packages/cloud_functions/cloud_functions/android/build.gradle index 9d1295a9567c..0e60c55e34f4 100644 --- a/packages/cloud_functions/cloud_functions/android/build.gradle +++ b/packages/cloud_functions/cloud_functions/android/build.gradle @@ -4,14 +4,18 @@ version '1.0-SNAPSHOT' apply plugin: 'com.android.library' apply from: file("local-config.gradle") -// AGP 9+ has built-in Kotlin support; older versions need the plugin explicitly. +// AGP 9+ has built-in Kotlin support unless Flutter opts out via android.builtInKotlin=false. 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' } buildscript { - ext.kotlin_version = "1.8.22" + ext.kotlin_version = "2.0.0" repositories { google() mavenCentral() @@ -61,12 +65,6 @@ android { targetCompatibility project.ext.javaVersion } - if (agpMajor < 9) { - kotlinOptions { - jvmTarget = project.ext.javaVersion - } - } - sourceSets { main.java.srcDirs += "src/main/kotlin" test.java.srcDirs += "src/test/kotlin" @@ -90,4 +88,12 @@ android { } +plugins.withId("org.jetbrains.kotlin.android") { + kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget(project.ext.javaVersion.toString()) + } + } +} + apply from: file("./user-agent.gradle") \ No newline at end of file diff --git a/packages/firebase_ai/firebase_ai/android/build.gradle b/packages/firebase_ai/firebase_ai/android/build.gradle index 13affc9f6740..278104b4b9c2 100644 --- a/packages/firebase_ai/firebase_ai/android/build.gradle +++ b/packages/firebase_ai/firebase_ai/android/build.gradle @@ -4,9 +4,13 @@ version '1.0-SNAPSHOT' apply plugin: 'com.android.library' apply from: file("local-config.gradle") -// AGP 9+ has built-in Kotlin support; older versions need the plugin explicitly. +// AGP 9+ has built-in Kotlin support unless Flutter opts out via android.builtInKotlin=false. 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' } @@ -33,12 +37,6 @@ android { targetCompatibility project.ext.javaVersion } - if (agpMajor < 9) { - kotlinOptions { - jvmTarget = project.ext.javaVersion - } - } - sourceSets { main.java.srcDirs += "src/main/kotlin" } @@ -47,3 +45,11 @@ android { disable 'InvalidPackage' } } + +plugins.withId("org.jetbrains.kotlin.android") { + kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget(project.ext.javaVersion.toString()) + } + } +} diff --git a/packages/firebase_analytics/firebase_analytics/android/build.gradle b/packages/firebase_analytics/firebase_analytics/android/build.gradle index 183ea4605c04..189e57e43906 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.0.0" repositories { google() mavenCentral() @@ -26,9 +26,13 @@ rootProject.allprojects { apply plugin: 'com.android.library' -// AGP 9+ has built-in Kotlin support; older versions need the plugin explicitly. +// AGP 9+ has built-in Kotlin support unless Flutter opts out via android.builtInKotlin=false. 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' } @@ -58,12 +62,6 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - if (agpMajor < 9) { - kotlinOptions { - jvmTarget = project.ext.javaVersion - } - } - compileOptions { sourceCompatibility project.ext.javaVersion targetCompatibility project.ext.javaVersion @@ -90,4 +88,12 @@ android { } } +plugins.withId("org.jetbrains.kotlin.android") { + kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget(project.ext.javaVersion.toString()) + } + } +} + apply from: file("./user-agent.gradle") \ No newline at end of file diff --git a/packages/firebase_app_check/firebase_app_check/android/build.gradle b/packages/firebase_app_check/firebase_app_check/android/build.gradle index 45c2fa4d6345..d4fdbc15fca9 100644 --- a/packages/firebase_app_check/firebase_app_check/android/build.gradle +++ b/packages/firebase_app_check/firebase_app_check/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.0.0" repositories { google() mavenCentral() @@ -19,9 +19,13 @@ rootProject.allprojects { } } -// AGP 9+ has built-in Kotlin support; older versions need the plugin explicitly. +// AGP 9+ has built-in Kotlin support unless Flutter opts out via android.builtInKotlin=false. 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' } @@ -51,12 +55,6 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - if (agpMajor < 9) { - kotlinOptions { - jvmTarget = project.ext.javaVersion - } - } - compileOptions { sourceCompatibility project.ext.javaVersion targetCompatibility project.ext.javaVersion @@ -84,4 +82,12 @@ android { } } +plugins.withId("org.jetbrains.kotlin.android") { + kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget(project.ext.javaVersion.toString()) + } + } +} + apply from: file("./user-agent.gradle") diff --git a/packages/firebase_database/firebase_database/android/build.gradle b/packages/firebase_database/firebase_database/android/build.gradle index 4826a7d16f7a..a0db4c898a25 100755 --- a/packages/firebase_database/firebase_database/android/build.gradle +++ b/packages/firebase_database/firebase_database/android/build.gradle @@ -4,9 +4,13 @@ version '1.0-SNAPSHOT' apply plugin: 'com.android.library' apply from: file("local-config.gradle") -// AGP 9+ has built-in Kotlin support; older versions need the plugin explicitly. +// AGP 9+ has built-in Kotlin support unless Flutter opts out via android.builtInKotlin=false. 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' } @@ -55,12 +59,6 @@ android { targetCompatibility project.ext.javaVersion } - if (agpMajor < 9) { - kotlinOptions { - jvmTarget = project.ext.javaVersion - } - } - sourceSets { main { java { @@ -85,5 +83,13 @@ android { } } +plugins.withId("org.jetbrains.kotlin.android") { + kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget(project.ext.javaVersion.toString()) + } + } +} + apply from: file("./user-agent.gradle") diff --git a/packages/firebase_performance/firebase_performance/android/build.gradle b/packages/firebase_performance/firebase_performance/android/build.gradle index 6d38c5620117..5f74989e1448 100644 --- a/packages/firebase_performance/firebase_performance/android/build.gradle +++ b/packages/firebase_performance/firebase_performance/android/build.gradle @@ -4,14 +4,18 @@ version '1.0-SNAPSHOT' apply plugin: 'com.android.library' apply from: file("local-config.gradle") -// AGP 9+ has built-in Kotlin support; older versions need the plugin explicitly. +// AGP 9+ has built-in Kotlin support unless Flutter opts out via android.builtInKotlin=false. 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' } buildscript { - ext.kotlin_version = "1.8.22" + ext.kotlin_version = "2.0.0" repositories { google() @@ -60,12 +64,6 @@ android { targetCompatibility project.ext.javaVersion } - if (agpMajor < 9) { - kotlinOptions { - jvmTarget = project.ext.javaVersion - } - } - sourceSets { main.java.srcDirs += "src/main/kotlin" test.java.srcDirs += "src/test/kotlin" @@ -87,4 +85,12 @@ android { } } +plugins.withId("org.jetbrains.kotlin.android") { + kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget(project.ext.javaVersion.toString()) + } + } +} + apply from: file("./user-agent.gradle") diff --git a/packages/firebase_remote_config/firebase_remote_config/android/build.gradle b/packages/firebase_remote_config/firebase_remote_config/android/build.gradle index a03f8e444446..d2a0aa74e23c 100644 --- a/packages/firebase_remote_config/firebase_remote_config/android/build.gradle +++ b/packages/firebase_remote_config/firebase_remote_config/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.0.0" repositories { google() mavenCentral() @@ -19,9 +19,13 @@ rootProject.allprojects { } } -// AGP 9+ has built-in Kotlin support; older versions need the plugin explicitly. +// AGP 9+ has built-in Kotlin support unless Flutter opts out via android.builtInKotlin=false. 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' } @@ -51,12 +55,6 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - if (agpMajor < 9) { - kotlinOptions { - jvmTarget = project.ext.javaVersion - } - } - compileOptions { sourceCompatibility project.ext.javaVersion targetCompatibility project.ext.javaVersion @@ -83,4 +81,12 @@ android { } } +plugins.withId("org.jetbrains.kotlin.android") { + kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget(project.ext.javaVersion.toString()) + } + } +} + apply from: file("./user-agent.gradle") diff --git a/packages/firebase_storage/firebase_storage/android/build.gradle b/packages/firebase_storage/firebase_storage/android/build.gradle index c9e5b5e5940d..f041bc40275b 100755 --- a/packages/firebase_storage/firebase_storage/android/build.gradle +++ b/packages/firebase_storage/firebase_storage/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.0.0" repositories { google() mavenCentral() @@ -44,9 +44,13 @@ def getRootProjectExtOrCoreProperty(name, firebaseCoreProject) { return rootProject.ext.get('FlutterFire').get(name) } -// AGP 9+ has built-in Kotlin support; older versions need the plugin explicitly. +// AGP 9+ has built-in Kotlin support unless Flutter opts out via android.builtInKotlin=false. 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' } @@ -63,12 +67,6 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - if (agpMajor < 9) { - kotlinOptions { - jvmTarget = project.ext.javaVersion - } - } - compileOptions { sourceCompatibility project.ext.javaVersion targetCompatibility project.ext.javaVersion @@ -95,4 +93,12 @@ android { } } +plugins.withId("org.jetbrains.kotlin.android") { + kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget(project.ext.javaVersion.toString()) + } + } +} + apply from: file("./user-agent.gradle")