From ae3327590c644811609f56d910e7ff6374659fdd Mon Sep 17 00:00:00 2001 From: Milind Goel Date: Fri, 29 May 2026 04:05:04 +0530 Subject: [PATCH] fix: remove kotlin-android since AGP 9 supports it https://github.com/fluttercommunity/flutter_workmanager/issues/667 --- workmanager_android/android/build.gradle | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/workmanager_android/android/build.gradle b/workmanager_android/android/build.gradle index 3552b1be..4ce77b98 100644 --- a/workmanager_android/android/build.gradle +++ b/workmanager_android/android/build.gradle @@ -9,7 +9,11 @@ rootProject.allprojects { } apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' +// 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) { + apply plugin: 'kotlin-android' +} android { // Conditional for compatibility with AGP <4.2. @@ -34,12 +38,13 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { - kotlinOptions.jvmTarget = "1.8" + if (agpMajor < 9) { + kotlinOptions { + tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { + kotlinOptions.jvmTarget = "1.8" + } } } - } dependencies {