Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throwing error in static Future<void> setServiceMethod(Function serviceMethod) while trying to start foreground service #4

Open
vaimikpatel2908 opened this issue Jan 23, 2020 · 7 comments

Comments

@vaimikpatel2908
Copy link

Exception has occurred.
NoSuchMethodError (NoSuchMethodError: The method 'toRawHandle' was called on null.
Receiver: null
Tried calling: toRawHandle())

@RBSoftwareBR
Copy link

Same here. any solutions?

@ChangJoo-Park
Copy link
Owner

Can you reproduce codes?

@pkotowski
Copy link

pkotowski commented Apr 28, 2020

Have the same problem. minSDK 23, max
Added: <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
Added: <service android:name="changjoopark.com.flutter_foreground_plugin.FlutterForegroundService"/>
Added: <uses-sdk android:minSdkVersion="23" tools:overrideLibrary="changjoopark.com.flutter_foreground_plugin" />`

gradle:

compileSdkVersion 28
minSdkVersion 23
targetSdkVersion 28

And error occurs, after copy-paste code from pub.dev:

E/flutter (10022): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The method 'toRawHandle' was called on null.
E/flutter (10022): Receiver: null
E/flutter (10022): Tried calling: toRawHandle()
E/flutter (10022): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
E/flutter (10022): #1 FlutterForegroundPlugin.setServiceMethod (package:flutter_foreground_plugin/flutter_foreground_plugin.dart:53:58)
E/flutter (10022): #2 ActivityWidgetState.startForegroundService (package:activity/view/activity/activity.dart:334:35)

@rvgroup
Copy link

rvgroup commented May 12, 2020

I also had this error. The called function must be static:

static void _globalForegroundService() {....}

@radheyjat
Copy link

Same Error trrigger when call await FlutterForegroundPlugin.setServiceMethod(globalForegroundService);
Without this method working fine but not call onStart & onStop method

@ghost
Copy link

ghost commented Feb 6, 2021

I also got the same error, but I moved startForegroundService and globalForegroundService Function to main.dart and it worked.

@willroyMyles
Copy link

I got this to work by moving startForegroundServices() outside of main class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants