background_locator_fixed
background_locator_fixed copied to clipboard
Android Release mode
Package is work in debug mode without any issues, but its not working on release mode
same problem on android and ios
background_locator: git: url: https://github.com/glofru/background_locator.git
That version seems to be working for me. Tested on flutter 3.7.0
Hey, I solved this by adding the annotation @pragma('vm:entry-point')
right above my callback function.
This prevents Flutter's compile time tree-shaking from changing the code when building in release mode.
See also this Stack Overflow answer.
This issue happened in several other packages like Firebase Messaging, Background Geolocation, and they solved it the same way.
Hi, PR https://github.com/Yukams/background_locator_fixed/pull/53 fixes it. It has been merged on the new 2.0.6 version, feel free to try it out and report back
no still not working by adding this @pragma('vm:entry-point')
I think v2.0.6 (latest version - PR) fix this issue.
Try to run the app in release mode but connected with usb with android studio open, check logcat to find the reason for the crash.
i update but the error continue on release mode.
At least on Flutter 3.10; with the latest version of this library; it still crashes on launch when running in release mode:
E/AndroidRuntime(13139): java.lang.RuntimeException: Unable to start service yukams.app.background_locator_2.IsolateHolderService@*** with Intent { act=START cmp={package_name}/yukams.app.background_locator_2.IsolateHolderService (has extras) }: java.lang.RuntimeException: Missing type parameter.
The solution proposed by @yamhoresh did not fix this for me.
@Yukams any thoughts on this issue?
After doing some digging, I did found a way to prevent the app from crashing; by changing LocationCallbackHandler.callback to the following on the registerLocationUpdate
init:
BackgroundLocator.registerLocationUpdate((params) async {
LocationServiceRepository myLocationCallbackRepository = LocationServiceRepository();
await myLocationCallbackRepository.callback(params);
},
...
);
This does however introduce new runtime errors; not sure if this is because the above impl. is incorrect or some other cause:
E/flutter (30810): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
E/flutter (30810): #0 SettingsUtil._getCommonArgumentsMap
settings_util.dart:38
E/flutter (30810): #1 SettingsUtil.getArgumentsMap
settings_util.dart:17
E/flutter (30810): #2 BackgroundLocator.registerLocationUpdate
Same
The reported behavior is strange. I don't have this problem neither on Android nor on iOS even in release mode.
However, I continue to use my fork. Try with it!
background_locator_2: git: url: https://github.com/tulioccalazans/background_locator_fixed.git ref: master
Below are the relevant specifications of the flutter I'm using:
flutter doctor -v
[√] Flutter (Channel stable, 3.7.7, on Microsoft Windows [versÆo 10.0.19044.2486], locale pt-BR) • Flutter version 3.7.7 on channel stable at C:\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 2ad6cd72c0 (3 months ago), 2023-03-08 09:41:59 -0800 • Engine revision 1837b5be5f • Dart version 2.19.4 • DevTools version 2.20.1
[√] Android Studio (version 2022.1) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
If I can help with anything, just let me know.
@tulioccalazans Is there supposed to be any difference between your fork and this repository? I tried it out; at first I got a compiler error stating that my version of Kotlin was outdated; after updating it in build.gradle it compiled, but still crashes on launch in release mode (android); same as before
Hi, I have two applications and I'm not having these kind of problems. Everything works perfectly.
@jannisnikoy
Do you have any source code that I can analyze to try to help you?
@jannisnikoy did you found the fix of the Null check operator error?