background_locator icon indicating copy to clipboard operation
background_locator copied to clipboard

No implementation found for io.flutter.view.FlutterCallbackInformation

Open williambarreiro opened this issue 4 years ago • 21 comments

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)

williambarreiro avatar Jan 14 '21 18:01 williambarreiro

Hi @WilliamFB Thank you for opening an issue;

Please share some code;

mehdok avatar Jan 15 '21 06:01 mehdok

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

williambarreiro avatar Jan 15 '21 12:01 williambarreiro

Did you set the callback in the initialize function?

mehdok avatar Jan 15 '21 12:01 mehdok

I think so, like this?

image

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

williambarreiro avatar Jan 15 '21 12:01 williambarreiro

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

BackgroundLocator.registerLocationUpdate(LocationCallbackHandler.callback,

mehdok avatar Jan 15 '21 17:01 mehdok

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

image image

williambarreiro avatar Jan 15 '21 18:01 williambarreiro

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

mehdok avatar Jan 16 '21 06:01 mehdok

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:

  • 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 or LocationCallbackHandler.initCallback I just call them directly, because they are in the same file, like i showed in registerLocationUpdate.

williambarreiro avatar Jan 21 '21 14:01 williambarreiro

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.

mehdok avatar Jan 22 '21 07:01 mehdok

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

williambarreiro avatar Jan 22 '21 13:01 williambarreiro

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;

mehdok avatar Jan 22 '21 13:01 mehdok

Same issue

Johan07 avatar Jan 25 '21 22:01 Johan07

same issue

bayuly94 avatar Feb 03 '21 00:02 bayuly94

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

qwert2603 avatar Feb 10 '21 14:02 qwert2603

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

oligazar avatar Mar 26 '21 09:03 oligazar

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

rueichang avatar Apr 19 '21 08:04 rueichang

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

Trteich avatar Aug 03 '21 18:08 Trteich

Same issue

Habil24 avatar Jan 21 '22 08:01 Habil24

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

It worked for me Thanks.

M-Ali-D avatar Apr 05 '22 07:04 M-Ali-D

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

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

Habil24 avatar Apr 08 '22 12:04 Habil24

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?

mahira13 avatar Jun 20 '22 07:06 mahira13

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

williambarreiro avatar Jan 04 '23 13:01 williambarreiro