rekabhq / background_locator

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

No implementation found for io.flutter.view.FlutterCallbackInformation #185

Closed williambarreiro closed 1 year ago

williambarreiro commented 3 years ago

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)

mehdok commented 3 years ago

Hi @WilliamFB Thank you for opening an issue;

Please share some code;

williambarreiro commented 3 years ago

This is the LocatorService.kt of the version i am using, the error occurs on line 81.

Captura de tela de 2021-01-15 09-03-44

mehdok commented 3 years ago

Did you set the callback in the initialize function?

williambarreiro commented 3 years ago

I think so, like this?

image

My version is at this point: https://github.com/rekab-app/background_locator/tree/8190a64bbb4968c5ecdf41333234490360e9c12d

mehdok commented 3 years ago

You are pointing to the library source code, show the usage in your code. something like this:

BackgroundLocator.registerLocationUpdate(LocationCallbackHandler.callback,
williambarreiro commented 3 years ago

Is this happening because i am calling startLocator at the wrong moment? Obs: The crash only happens on a few devices.

image image

mehdok commented 3 years ago

What do you mean by the wrong moment? Are you running the example app?

williambarreiro commented 3 years ago

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:

image

image

The registerLocationUpdate: image

Using the unRegisterLocationUpdate: image

There are 2 differences:

mehdok commented 3 years ago

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.

williambarreiro commented 3 years ago

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!!

mehdok commented 3 years ago

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;

Johan07 commented 3 years ago

Same issue

bayuly94 commented 3 years ago

same issue

qwert2603 commented 3 years ago

Adding FlutterInjector.instance().flutterLoader().ensureInitializationComplete(context, arrayOf()) has helped me.

oligazar commented 3 years ago

@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?

rueichang commented 3 years ago

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..

Trteich commented 3 years ago

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

Habil24 commented 2 years ago

Same issue

M-Ali-D commented 2 years ago

Adding FlutterInjector.instance().flutterLoader().ensureInitializationComplete(context, arrayOf()) has helped me.

It worked for me Thanks.

Habil24 commented 2 years ago

Adding FlutterInjector.instance().flutterLoader().ensureInitializationComplete(context, arrayOf()) has helped me.

Hi, where should we add this line in our app?

mahira13 commented 2 years ago

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?

williambarreiro commented 1 year ago

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...