From 9d6c6572cf69101844dde26063536a589049da9b Mon Sep 17 00:00:00 2001 From: BriceFab Date: Tue, 4 Aug 2026 14:39:41 +0200 Subject: [PATCH] fix(android): set Pigeon Kotlin package for AGP 8 / Kotlin 2.2+ Kotlin rejects default-package imports into a named package, so WakelockPlusPlugin failed to compile and GeneratedPluginRegistrant reported cannot find symbol. Point Pigeon KotlinOptions.package at dev.fluttercommunity.plus.wakelock and drop obsolete imports. --- wakelock_plus/CHANGELOG.md | 5 +++++ .../kotlin/dev/fluttercommunity/plus/wakelock/Wakelock.kt | 2 -- .../fluttercommunity/plus/wakelock/WakelockPlusMessages.g.kt | 2 ++ .../dev/fluttercommunity/plus/wakelock/WakelockPlusPlugin.kt | 4 ---- wakelock_plus/pigeons/messages.dart | 5 ++++- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/wakelock_plus/CHANGELOG.md b/wakelock_plus/CHANGELOG.md index 6d078c5..947d423 100644 --- a/wakelock_plus/CHANGELOG.md +++ b/wakelock_plus/CHANGELOG.md @@ -1,3 +1,8 @@ +## [Unreleased] +* Fix Android build on AGP 8 / Kotlin 2.2+ by setting Pigeon `KotlinOptions.package` + so generated API types are not left in the default package (fixes missing + `WakelockPlusPlugin` / `cannot find symbol` in `GeneratedPluginRegistrant`). + ## [1.7.0] * [#134](https://github.com/fluttercommunity/wakelock_plus/pull/134): fix(android): defer wakelock toggle when no activity is attached. Thanks [sadaqatdev](https://github.com/sadaqatdev). * [#136](https://github.com/fluttercommunity/wakelock_plus/pull/136): Migrated plugin to Built-in Kotlin Gradle Plugin (KGP). Thanks [drmirk](https://github.com/drmirk). diff --git a/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/Wakelock.kt b/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/Wakelock.kt index 36e5027..1872aae 100644 --- a/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/Wakelock.kt +++ b/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/Wakelock.kt @@ -1,7 +1,5 @@ package dev.fluttercommunity.plus.wakelock -import IsEnabledMessage -import ToggleMessage import android.app.Activity import android.view.WindowManager diff --git a/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/WakelockPlusMessages.g.kt b/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/WakelockPlusMessages.g.kt index 2d4b1d0..5c473a7 100644 --- a/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/WakelockPlusMessages.g.kt +++ b/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/WakelockPlusMessages.g.kt @@ -2,6 +2,8 @@ // See also: https://pub.dev/packages/pigeon @file:Suppress("UNCHECKED_CAST", "ArrayInDataClass") +package dev.fluttercommunity.plus.wakelock + import android.util.Log import io.flutter.plugin.common.BasicMessageChannel diff --git a/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/WakelockPlusPlugin.kt b/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/WakelockPlusPlugin.kt index bd182ec..19c3a3d 100644 --- a/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/WakelockPlusPlugin.kt +++ b/wakelock_plus/android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/WakelockPlusPlugin.kt @@ -1,9 +1,5 @@ package dev.fluttercommunity.plus.wakelock -import IsEnabledMessage -import ToggleMessage -import WakelockPlusApi - import io.flutter.embedding.engine.plugins.FlutterPlugin import io.flutter.embedding.engine.plugins.activity.ActivityAware import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding diff --git a/wakelock_plus/pigeons/messages.dart b/wakelock_plus/pigeons/messages.dart index e6100b5..d24732c 100644 --- a/wakelock_plus/pigeons/messages.dart +++ b/wakelock_plus/pigeons/messages.dart @@ -21,7 +21,10 @@ class IsEnabledMessage { prefix: 'WAKELOCKPLUS', headerIncludePath: './include/wakelock_plus/messages.g.h', ), - kotlinOptions: KotlinOptions(errorClassName: "WakelockPlusFlutterError"), + kotlinOptions: KotlinOptions( + errorClassName: "WakelockPlusFlutterError", + package: "dev.fluttercommunity.plus.wakelock", + ), kotlinOut: 'android/src/main/kotlin/dev/fluttercommunity/plus/wakelock/WakelockPlusMessages.g.kt', ),