rekabhq / background_locator

A Flutter plugin for updating location in background.
MIT License
288 stars 329 forks source link

App crach on restart #171

Open Sly2024 opened 3 years ago

Sly2024 commented 3 years ago

I use the plugging with the "Stop on app terminate" function. It works fine but if the app is terminated while the service is still active, I get the following fatal error on restart: E/AndroidRuntime( 6559): FATAL EXCEPTION: main E/AndroidRuntime( 6559): Process: fr.monguide.paris.gratuit, PID: 6559 E/AndroidRuntime( 6559): android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{7d47961 u0 fr.monguide.paris.gratuit/rekab.app.background_locator.IsolateHolderService} E/AndroidRuntime( 6559): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1945) E/AndroidRuntime( 6559): at android.os.Handler.dispatchMessage(Handler.java:107) E/AndroidRuntime( 6559): at android.os.Looper.loop(Looper.java:214) E/AndroidRuntime( 6559): at android.app.ActivityThread.main(ActivityThread.java:7356) E/AndroidRuntime( 6559): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 6559): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) E/AndroidRuntime( 6559): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Anyone experiencing the same issue ?

sanidhyaagrawal commented 3 years ago

I am facing the same issue, were you able to resolve this?

Sly2024 commented 3 years ago

Sadly no. I tried to modify some part of the plugin but none of the modification worked for me. If you find a solution, I would be very grateful.

sanidhyaagrawal commented 3 years ago

@mehdok can you please help with this?

Running on POCO F1 device, Failing on SDK version 28 (Android 9) only. Tested on various devices with lower SDK versions.

Code to start- if (IsolateNameServer.lookupPortByName(isolateName) != null) IsolateNameServer.removePortNameMapping(isolateName); IsolateNameServer.registerPortWithName(port.sendPort, isolateName); if (!await BackgroundLocator.isServiceRunning()) await BackgroundLocator.initialize();

Code to end- if (await BackgroundLocator.isServiceRunning()) await BackgroundLocator.unRegisterLocationUpdate(); if (IsolateNameServer.lookupPortByName(isolateName) != null) IsolateNameServer.removePortNameMapping(isolateName);

sadrohan commented 3 years ago

@mehdok I am also having the same issue plz look into this.

sanidhyaagrawal commented 3 years ago

@mehdok can you please help with this?

Running on POCO F1 device, Failing on SDK version 28 (Android 9) only. Tested on various devices with lower SDK versions.

Code to start- if (IsolateNameServer.lookupPortByName(isolateName) != null) IsolateNameServer.removePortNameMapping(isolateName); IsolateNameServer.registerPortWithName(port.sendPort, isolateName); if (!await BackgroundLocator.isServiceRunning()) await BackgroundLocator.initialize();

Code to end- if (await BackgroundLocator.isServiceRunning()) await BackgroundLocator.unRegisterLocationUpdate(); if (IsolateNameServer.lookupPortByName(isolateName) != null) IsolateNameServer.removePortNameMapping(isolateName);

WhatsApp Image 2021-01-11 at 12 24 44 AM

mehdok commented 3 years ago

Hi guys,

Thank you for opening an issue and participating to provide more info. I'm aware of this bug, but right now I don't have enough time to spend on it;

marcoheine commented 3 years ago

Does anyone having a solution for this? @sanidhyaagrawal @sadrohan @Sly2024