background_locator
background_locator copied to clipboard
No implementation found for io.flutter.view.FlutterCallbackInformation
I am getting the following error, any suggestion?
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:30) at rekab.app.background_locator.LocatorService.startLocatorService(LocatorService.kt:81) at rekab.app.background_locator.LocatorService.onCreate(LocatorService.kt:69) at android.app.ActivityThread.handleCreateService(ActivityThread.java:3380) at android.app.ActivityThread.-wrap4() at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1711) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6548) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857)
Hi @WilliamFB Thank you for opening an issue;
Please share some code;
This is the LocatorService.kt of the version i am using, the error occurs on line 81.
Did you set the callback in the initialize
function?
I think so, like this?
My version is at this point: https://github.com/rekab-app/background_locator/tree/8190a64bbb4968c5ecdf41333234490360e9c12d
You are pointing to the library source code, show the usage in your code. something like this:
BackgroundLocator.registerLocationUpdate(LocationCallbackHandler.callback,
Is this happening because i am calling startLocator
at the wrong moment? Obs: The crash only happens on a few devices.
What do you mean by the wrong moment? Are you running the example app?
Sorry @mehdok, i didn't want to say "wrong time", let's forget it. I will show some information below;
I am using bg_locator 1.2.2+1 and flutter 1.20.0;
My implementation is like the example, but there are some differences. I will show the differences after the implementation;
This is in my first screen initState
:
The registerLocationUpdate
:
Using the unRegisterLocationUpdate
:
There are 2 differences:
-
I don't use these two lines in my callback, because i send my location to a queue and i don't need to send it to my main Isolate:
final SendPort send = IsolateNameServer.lookupPortByName(_isolateName);
send?.send(locationDto);
-
I am not calling the functions in a separate class, like:
LocationCallbackHandler.callback
orLocationCallbackHandler.initCallback
I just call them directly, because they are in the same file, like i showed inregisterLocationUpdate
.
I'm not sure if this is the problem, but we have to eliminate its possibility :)
Your callback
function must be global
or static
, is it?
If yes, please put your callback
in a separate file to see if it's working or not.
The callback is static, but anyway, i will separate the callback in a service. As soon as i know the results i tell you. Thanks!!
While you are testing, it would be nice if you could test the example app to see if it's working for you or not, if the example app is working and your app doesn't, it would ease the debug process if you create a simple repository with your implementation;
Same issue
same issue
Adding FlutterInjector.instance().flutterLoader().ensureInitializationComplete(context, arrayOf())
has helped me.
@mehdok
I have the same issue on line val callbackInfo = FlutterCallbackInformation.lookupCallbackInformation(callbackHandle)
Registration for location updates, where _onLocationData
is static
:
await BackgroundLocator.registerLocationUpdate(_onLocationData,
initCallback: _onInitBackgroundLocation,
initDataCallback: data,
disposeCallback: _onDispose,
...
Has anybody found the reason and solution or workaround?
I got the same issue even the example app. This problem can be reproduced by rebooting the smart phone. I had installed the example app first. Starting the service and ensure the service is running. Then I reboot the smart phone again and open the example app afterward. The APP will be crash and show the error message which is same as WilliamFB. And APP won't be able to start properly... My Android is 9.0..
Any updates? I've found that this crash appeares on app killing while service is running(not 100% reproducible). As I investigated, service tries to be recreated, and reffer to flutter part of app, but it is dead. Sorry for my confusing explanation, but since this happens when the application is killed, I have no way to debug. Tried to return START_NON_STICKY from onStartComand(). It helpend on clean Android, but no effect on fu**ing Samsung. It seems like Samsung ignores START_NON_STICKY.
I'm completely not sure that my solution is right.
Also have an idea to cover all LocatorService.startLocatorService() into try/catch block, but it looks like a crutch
Same issue
Adding
FlutterInjector.instance().flutterLoader().ensureInitializationComplete(context, arrayOf())
has helped me.
It worked for me Thanks.
Adding
FlutterInjector.instance().flutterLoader().ensureInitializationComplete(context, arrayOf())
has helped me.
Hi, where should we add this line in our app?
Adding
FlutterInjector.instance().flutterLoader().ensureInitializationComplete(context, arrayOf())
has helped me.Hi, where should we add this line in our app?
did you find where to add this line?
I was using a very old version of the plugin, so i'm closing this issue. I recommend you take a look here: https://github.com/rekabhq/background_locator/issues/340 Since the package is no longer being updated, they forked it and fixed some common problems...