From 7fe18628890e187d77cfea7c5b7ef919fe2ad3f4 Mon Sep 17 00:00:00 2001 From: drmirk Date: Sun, 31 May 2026 01:31:30 +0600 Subject: [PATCH 1/3] Migrated plugin to Built-in Kotlin Gradle Plugin (KGP) --- wakelock_plus/CHANGELOG.md | 4 ++++ wakelock_plus/android/build.gradle | 9 ++++----- wakelock_plus/example/android/app/build.gradle | 7 ++++--- wakelock_plus/example/android/gradle.properties | 3 +++ wakelock_plus/pubspec.yaml | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/wakelock_plus/CHANGELOG.md b/wakelock_plus/CHANGELOG.md index da5027c..c772de5 100644 --- a/wakelock_plus/CHANGELOG.md +++ b/wakelock_plus/CHANGELOG.md @@ -1,3 +1,7 @@ +## [1.7.0] +* Android + - Migrated plugin to Built-in Kotlin Gradle Plugin (KGP) + ## [1.6.1] * [#133](https://github.com/fluttercommunity/wakelock_plus/pull/133): wakelock_plus Flutter 3.38 downgrade. Thanks [diegotori](https://github.com/diegotori). - Library now requires Dart version `3.10` or higher, restoring previous compatibility. diff --git a/wakelock_plus/android/build.gradle b/wakelock_plus/android/build.gradle index d2a1ffe..985a60d 100644 --- a/wakelock_plus/android/build.gradle +++ b/wakelock_plus/android/build.gradle @@ -2,7 +2,6 @@ group 'dev.fluttercommunity.plus.wakelock' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '2.2.0' repositories { google() mavenCentral() @@ -21,7 +20,6 @@ rootProject.allprojects { } apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' android { namespace 'dev.fluttercommunity.plus.wakelock' @@ -32,8 +30,10 @@ android { targetCompatibility JavaVersion.VERSION_17 } - kotlinOptions { - jvmTarget = '17' + kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 + } } lintOptions { disable 'InvalidPackage' @@ -51,7 +51,6 @@ android { } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" testImplementation 'org.jetbrains.kotlin:kotlin-test' testImplementation 'org.mockito:mockito-core:5.0.0' } diff --git a/wakelock_plus/example/android/app/build.gradle b/wakelock_plus/example/android/app/build.gradle index c53cd6c..628dc74 100644 --- a/wakelock_plus/example/android/app/build.gradle +++ b/wakelock_plus/example/android/app/build.gradle @@ -1,6 +1,5 @@ plugins { id 'com.android.application' - id 'kotlin-android' id 'dev.flutter.flutter-gradle-plugin' } def localProperties = new Properties() @@ -31,8 +30,10 @@ android { targetCompatibility JavaVersion.VERSION_17 } - kotlinOptions { - jvmTarget = '17' + kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 + } } sourceSets { diff --git a/wakelock_plus/example/android/gradle.properties b/wakelock_plus/example/android/gradle.properties index bee0af8..83926bf 100644 --- a/wakelock_plus/example/android/gradle.properties +++ b/wakelock_plus/example/android/gradle.properties @@ -1,3 +1,6 @@ org.gradle.jvmargs=-Xmx4g android.useAndroidX=true android.enableJetifier=true +android.builtInKotlin=true +# This newDsl flag was added automatically by Flutter migrator +android.newDsl=false diff --git a/wakelock_plus/pubspec.yaml b/wakelock_plus/pubspec.yaml index a555046..926bb1e 100644 --- a/wakelock_plus/pubspec.yaml +++ b/wakelock_plus/pubspec.yaml @@ -2,7 +2,7 @@ name: wakelock_plus description: >-2 Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, Windows, Linux, and web. -version: 1.6.1 +version: 1.7.0 repository: https://github.com/fluttercommunity/wakelock_plus/tree/main/wakelock_plus environment: From 8801fad002c12cc0977d05efd9cbed09f95fc07c Mon Sep 17 00:00:00 2001 From: drmirk Date: Sun, 31 May 2026 02:19:05 +0600 Subject: [PATCH 2/3] Fix: Migrated plugin to Built-in Kotlin Version Reverted --- wakelock_plus/CHANGELOG.md | 4 ---- wakelock_plus/pubspec.yaml | 10 +++++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/wakelock_plus/CHANGELOG.md b/wakelock_plus/CHANGELOG.md index c772de5..da5027c 100644 --- a/wakelock_plus/CHANGELOG.md +++ b/wakelock_plus/CHANGELOG.md @@ -1,7 +1,3 @@ -## [1.7.0] -* Android - - Migrated plugin to Built-in Kotlin Gradle Plugin (KGP) - ## [1.6.1] * [#133](https://github.com/fluttercommunity/wakelock_plus/pull/133): wakelock_plus Flutter 3.38 downgrade. Thanks [diegotori](https://github.com/diegotori). - Library now requires Dart version `3.10` or higher, restoring previous compatibility. diff --git a/wakelock_plus/pubspec.yaml b/wakelock_plus/pubspec.yaml index 926bb1e..45a3b04 100644 --- a/wakelock_plus/pubspec.yaml +++ b/wakelock_plus/pubspec.yaml @@ -1,12 +1,12 @@ name: wakelock_plus -description: >-2 +description: >2- Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, Windows, Linux, and web. -version: 1.7.0 +version: 1.6.1 repository: https://github.com/fluttercommunity/wakelock_plus/tree/main/wakelock_plus environment: - sdk: '>=3.10.0 <4.0.0' + sdk: ">=3.10.0 <4.0.0" flutter: ">=3.38.0" dependencies: @@ -33,7 +33,7 @@ dev_dependencies: flutter_lints: ^6.0.0 pigeon: ^26.2.3 # dart run pigeon --input "pigeons/messages.dart" mocktail: ^1.0.5 - + # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec @@ -99,4 +99,4 @@ flutter: # https://flutter.dev/custom-fonts/#from-packages assets: - - packages/wakelock_plus/assets/no_sleep.js \ No newline at end of file + - packages/wakelock_plus/assets/no_sleep.js From 3eddfcdfdcb0741b2eb7349a6a580943aa12bbe1 Mon Sep 17 00:00:00 2001 From: drmirk Date: Tue, 9 Jun 2026 01:34:18 +0600 Subject: [PATCH 3/3] Fix: Supporting Flutter versions earlier than 3.44 after kgp migration --- wakelock_plus/android/build.gradle | 18 +++++++++++++----- wakelock_plus/example/android/app/build.gradle | 12 +++++++----- .../example/android/gradle.properties | 4 +++- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/wakelock_plus/android/build.gradle b/wakelock_plus/android/build.gradle index 985a60d..b6479c0 100644 --- a/wakelock_plus/android/build.gradle +++ b/wakelock_plus/android/build.gradle @@ -21,6 +21,11 @@ rootProject.allprojects { apply plugin: 'com.android.library' +def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int +if (agpMajor < 9) { + apply plugin: 'kotlin-android' +} + android { namespace 'dev.fluttercommunity.plus.wakelock' compileSdk = flutter.compileSdkVersion @@ -30,11 +35,6 @@ android { targetCompatibility JavaVersion.VERSION_17 } - kotlin { - compilerOptions { - jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 - } - } lintOptions { disable 'InvalidPackage' } @@ -68,3 +68,11 @@ android { } } } + + +kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 + } +} + diff --git a/wakelock_plus/example/android/app/build.gradle b/wakelock_plus/example/android/app/build.gradle index 628dc74..215ca60 100644 --- a/wakelock_plus/example/android/app/build.gradle +++ b/wakelock_plus/example/android/app/build.gradle @@ -30,11 +30,6 @@ android { targetCompatibility JavaVersion.VERSION_17 } - kotlin { - compilerOptions { - jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 - } - } sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -60,6 +55,13 @@ android { } } +kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 + } +} + + flutter { source '../..' } diff --git a/wakelock_plus/example/android/gradle.properties b/wakelock_plus/example/android/gradle.properties index 83926bf..6a41485 100644 --- a/wakelock_plus/example/android/gradle.properties +++ b/wakelock_plus/example/android/gradle.properties @@ -1,6 +1,8 @@ org.gradle.jvmargs=-Xmx4g android.useAndroidX=true android.enableJetifier=true -android.builtInKotlin=true + +# This builtInKotlin flag was added automatically by Flutter migrator +android.builtInKotlin=false # This newDsl flag was added automatically by Flutter migrator android.newDsl=false