rekabhq / background_locator

A Flutter plugin for updating location in background.
MIT License
289 stars 330 forks source link

App Crash while changing location permission from settings in Android devices #271

Open quadir1188 opened 3 years ago

quadir1188 commented 3 years ago

Fatal Exception: java.lang.UnsatisfiedLinkError: No implementation found for io.flutter.view.FlutterCallbackInformation io.flutter.embedding.engine.FlutterJNI.nativeLookupCallbackInformation(long) (tried Java_io_flutter_embedding_engine_FlutterJNI_nativeLookupCallbackInformation and Java_io_flutter_embedding_engine_FlutterJNI_nativeLookupCallbackInformation__J) at io.flutter.embedding.engine.FlutterJNI.nativeLookupCallbackInformation(FlutterJNI.java) at io.flutter.view.FlutterCallbackInformation.lookupCallbackInformation(FlutterCallbackInformation.java:28) at rekab.app.background_locator.IsolateHolderExtensionKt.startLocatorService(IsolateHolderExtension.kt:27) at rekab.app.background_locator.IsolateHolderService.onCreate(IsolateHolderService.kt:64) at android.app.ActivityThread.handleCreateService(ActivityThread.java:4214) at android.app.ActivityThread.access$200(ActivityThread.java:240) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2081) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:228) at android.app.ActivityThread.main(ActivityThread.java:7782) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)

mehdok commented 3 years ago

Hi @quadir1188 Thank you for opening an issue;

quadir1188 commented 3 years ago

Hello @mehdok Thank you for the reply.

mehdok commented 3 years ago

So you change the permission to Deny or Ask every time and starting the plugin?

Please keep in mind that the plugin doesn't check the permission, It is your job to check if the permission is granted or not, if it is granted then start the plugin;

If your app is running and you changing the permission (downgrading it), Android will terminate the application, so it's normal for the app to crash;

quadir1188 commented 3 years ago

Yes, I am starting plugin after user grant permission to "Allow always" or "Allow while using the App" only .This crash occurs If we are changing location permission manually from phone setting.

mehdok commented 3 years ago

Please write a scenario for this, so I can follow your steps to produce this error. It would be nice if you could provide a minimal working example.

quadir1188 commented 3 years ago

Yes, please check below link for app video. Background Locator app example video link : https://drive.google.com/file/d/1iV04bWuqBPU_SZjL2HBOiDXEtFY6h6aB/view If we are downgrading app permission from phone setting then it stops app and shows crash at crashlytics. My App video: https://drive.google.com/file/d/1mXJAhgbJ3EOI22xyA6HFKmxnVLnN6-Cq/view Please let me know if you require any further information

jbxbergdev commented 3 years ago

One possible fix is by modifying the IsolateHolderService.startLocatorService() method in IsolateHolderExtension.kt in a way that IsolateHolderService.backgroundEngine gets initialized earlier: https://github.com/oligazar/background_locator/blob/master/android/src/main/kotlin/rekab/app/background_locator/IsolateHolderExtension.kt I don't know if that fixes the root problem, but at least the crash doesn't occur. @mehdok would you be interested in a PR with the changes?

mehdok commented 3 years ago

@quadir1188

I saw your videos, this is normal behavior for Android and iOS.

If your app is running and you changing the permission (downgrading it), Android will terminate the application, so it's normal for the app to crash;

Also, take a look at this:

Android Revoke Permissions when App is running - Can I recover the App

mehdok commented 3 years ago

@jbxbergdev Thank you for your comment.

I can see that you added a try catch, am I right? Catching an unknown error in a try catch is one of the worst abilities of Java and Kotlin and may lead you to a lot of problems later;

jbxbergdev commented 3 years ago

@mehdok I'm actually not the one who implemented this. From what I understand, the try/catch might be for logging purposes and therefore isn't critical.

jbxbergdev commented 3 years ago

Hi @mehdok, any updates on this issue?

jbxbergdev commented 2 years ago

@mehdok ping