background_locator_fixed icon indicating copy to clipboard operation
background_locator_fixed copied to clipboard

Android Release mode

Open salehrezaie opened this issue 2 years ago • 14 comments

Package is work in debug mode without any issues, but its not working on release mode

salehrezaie avatar Jan 22 '23 09:01 salehrezaie

same problem on android and ios

tmauricio avatar Jan 24 '23 06:01 tmauricio

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

n0tc0ding avatar Jan 25 '23 01:01 n0tc0ding

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.

yamhoresh avatar Feb 11 '23 10:02 yamhoresh

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

Yukams avatar Mar 08 '23 14:03 Yukams

no still not working by adding this @pragma('vm:entry-point')

ram-wappnet avatar Mar 18 '23 14:03 ram-wappnet

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.

tulioccalazans avatar May 04 '23 14:05 tulioccalazans

i update but the error continue on release mode.

LGPdeveloperMobile avatar May 20 '23 17:05 LGPdeveloperMobile

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?

jannisnikoy avatar May 24 '23 03:05 jannisnikoy

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

jannisnikoy avatar May 24 '23 16:05 jannisnikoy

Same

nenio1949 avatar Jun 01 '23 08:06 nenio1949

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 avatar Jun 01 '23 12:06 tulioccalazans

@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

jannisnikoy avatar Jun 01 '23 14:06 jannisnikoy

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?

tulioccalazans avatar Jun 13 '23 18:06 tulioccalazans

@jannisnikoy did you found the fix of the Null check operator error?

MSF01 avatar May 08 '24 18:05 MSF01