flutter_background_service
flutter_background_service copied to clipboard
`flutter_background_service_android` threw an error
Whenever I build the app, I keep getting the below line in my debug console.
flutter_background_service_android
threw an error: Exception: This class should only be used in the main isolate (UI App). The app may not function as expected until you remove this plugin from pubspec.yaml
I tried removing the flutter_background_service_android package from the dependency but the same line of message still prompts. However, the app is still able to build. Can I know how to fix this?
I had the same issue and i fixed with downgrade flutter_background_service_android to version 6.0.1.
flutter pub downgrade flutter_background_service_android
I know it is a temporary solution but better than nothing :)
Preveously it was working , but now I got same issue.
I have the same problem.
Info:
flutter_background_service: ^5.0.2
bool isServiceRunning = await FlutterBackgroundService().isRunning();
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method isServiceRunning on channel id.flutter/background_service/android/method) #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:308:7) <asynchronous suspension> #1 FlutterBackgroundServiceAndroid.isServiceRunning (package:flutter_background_service_android/flutter_background_service_android.dart:114:18) <asynchronous suspension> #2 GeneralAppController.startBackgroundService (package:sample_project/app/general_app_controller.dart:130:29) <asynchronous suspension>
Same here, any updates?
@ekasetiawans same issue, any updates?
Everyone please check pr #392 . I have proposed a solution. Cheers, Thanks.
Its might you are accesing method from the background service isolate that only available for main isolate. For example, you starting service, from the onStart method or any api calls to the FlutterBakcgroundService class directly. You should only call apis that available for serviceInstance.
But I am just running the main.dart given in package example. Still getting the same exception.
But I am just running the main.dart given in package example. Still getting the same exception.
I have re-checked it's the example project run normally in my side.
But I am just running the main.dart given in package example. Still getting the same exception.
I also have this error :
Launching lib/main.dart on Nexus 5 in debug mode...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
V/BackgroundService(26354): Starting flutter engine for background service
V/BackgroundService(26354): Service already running, using existing service
I/flutter (26354): `flutter_background_service_android` threw an error: Exception: This class should only be used in the main isolate (UI App). The app may not function as expected until you remove this plugin from pubspec.yaml
Same issue
same issue
same here
same issue, any workaround?
same issue
same issue
same issue
same issue
same issue flutter_background_service_android` threw an error: This class should only be used in the main isolate (UI App). The app may not function as expected until you remove this plugin from pubspec.yaml
same issue as @AwaisQazii on android 12
same issue
@pragma('vm:entry-point') void onStart(ServiceInstance service) async { // Only available for flutter 3.0.0 and later DartPluginRegistrant.ensureInitialized(); <<---remove this code, will not throw exceptions
// For flutter prior to version 3.0.0 // We have to register the plugin manually
SharedPreferences preferences = await SharedPreferences.getInstance(); ... }
seems run twice?
I got same issue on 5.0.5
I have the same issue. @yanllllk's solution seems to work but I'm not sure if it's safe to use?
same issue flutter_background_service_android` threw an error: This class should only be used in the main isolate (UI App). The app may not function as expected until you remove this plugin from pubspec.yaml
I am facing the same issue but when I try to Turn On the "Manage Notification" manually, It is showing me that notification as well as it is updating the data based on the interval.
Take a look it it can help you. I don't know whether I'll get any issues in the future or not.
Update: As suggested by @yanllllk I've removed that line and it's not showing that warning anymore in logs.
same issue and soultion?
i have the same issue
Just add two lines to your pubspec.yaml file:
flutter_background_service: any flutter_background_service_android: "6.0.1"
This worked for me. I know this simply downgrades the flutter_background_service_android package and adjusts flutter_background_service accordingly. However, until this issue is fixed in the future, this solution should suffice.
It is breaking the background service in 6.2.3. App no longer works in the background after throwing this error Exception: This class should only be used in the main isolate (UI App)
Device - Pixel 6a