Skip to content

🐞Unable to call native code from Workmanager[Android Native Methods] #655

@AATMAN-ATOMIK

Description

@AATMAN-ATOMIK
  • I have read the README
  • I have done the setup for Android
  • I have done the setup for iOS
  • I have ran the sample app and it does not work there

Version

Technology Version
Workmanager version 0.9.0+3
Xcode version 16.2

Describe the error
Hello, community. I am registering a periodic task with the work manager package. I have tried calling the method channel with the following code:

void callbackDispatcher() {
  Workmanager().executeTask((task, inputData) async {
    print("======================================== WorkManager");
    await logToFile("======================================== WorkManager");

    WidgetsFlutterBinding.ensureInitialized();

    print("WorkManager : Task started: $task");
    await logToFile("WorkManager : Task started: $task");

    print("WorkManager : Input data: $inputData");
    await logToFile("WorkManager : Input data: $inputData");

 try {
      if (task == taskMidnightAPI) {
          static const MethodChannel _channel = MethodChannel('mypackage/custom_notifications');
           final res = await _channel.invokeMethod('scheduleDailyAlarm', {
            'id': id,
            'hour': hour,
            'minute': minute,
          });
      }
   } catch (e, stackTrace) {
      log(e.toString(), error: e, stackTrace: stackTrace, name: "WORK MANAGER(CALL BACK ERROR)");
    } 
}

But I am getting following error:

MissingPluginException(No implementation found for method scheduleDailyAlarm on channel mypackage/custom_notifications)

Output of flutter doctor -v
[!] Flutter (Channel stable, 3.35.5, on macOS 14.5 23F79 darwin-x64, locale en-US) [2.3s]
• Flutter version 3.35.5 on channel stable at /Users/infibraindev/Documents/softwares/flutter_v3.35.5
! Warning: flutter on your path resolves to /Users/infibraindev/Documents/Softwares/flutter_v3.35.5/bin/flutter, which is not inside your current Flutter SDK
checkout at /Users/infibraindev/Documents/softwares/flutter_v3.35.5. Consider adding /Users/infibraindev/Documents/softwares/flutter_v3.35.5/bin to the front of your
path.
! Warning: dart on your path resolves to /Users/infibraindev/Documents/Softwares/flutter_v3.35.5/bin/dart, which is not inside your current Flutter SDK checkout at
/Users/infibraindev/Documents/softwares/flutter_v3.35.5. Consider adding /Users/infibraindev/Documents/softwares/flutter_v3.35.5/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ac4e799d23 (6 weeks ago), 2025-09-26 12:05:09 -0700
• Engine revision d3d45dcf25
• Dart version 3.9.2
• DevTools version 2.48.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-lldb-debugging
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[!] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [5.7s]
• Android SDK at /Users/infibraindev/Library/Android/sdk
• Emulator version 35.6.11.0 (build_id 13610412) (CL:N/A)
• Platform android-36.1, build-tools 36.0.0
• ANDROID_HOME = /Users/infibraindev/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: flutter config --jdk-dir="path/to/jdk".
• Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[✓] Xcode - develop for iOS and macOS (Xcode 16.2) [5.0s]
• Xcode at /Applications/Xcode_16.2.app/Contents/Developer
• Build 16C5032a
• CocoaPods version 1.16.2

[✓] Chrome - develop for the web [23ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [21ms]
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)

[✓] VS Code (version 1.105.1) [18ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.122.0

[✓] Connected device (3 available) [7.2s]
• sdk gphone16k x86 64 (mobile) • emulator-5554 • android-x64 • Android 16 (API 36) (emulator)
• macOS (desktop) • macos • darwin-x64 • macOS 14.5 23F79 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 142.0.7444.60

[✓] Network resources [584ms]
• All expected network resources are available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions