flutter_background_geolocation not working in release mode
Asked Answered
C

1

7

I set up everything without skipping a single point from this plugin. It's working in all debug modes (Foreground, Background, Kill stat).

ERROR LOG: While killing the app in release mode

E/FlutterGeolocator(24131): Geolocator position updates stopped
D/FlutterGeolocator(24131): Stopping location service.
D/FlutterLocationService(24131): Unbinding from location service.
D/FlutterLocationService(24131): Destroying service.
E/flutter (24131): [ERROR:flutter/shell/common/shell.cc(93)] Dart Error: Dart_LookupLibrary: library 'package:flutter_background_geolocation/flutter_background_geolocation.dart' not found.
E/flutter (24131): [ERROR:flutter/runtime/dart_isolate.cc(668)] Could not resolve main entrypoint function.
E/flutter (24131): [ERROR:flutter/runtime/dart_isolate.cc(167)] Could not run the run main Dart entrypoint.
E/flutter (24131): [ERROR:flutter/runtime/runtime_controller.cc(385)] Could not create root isolate.
E/flutter (24131): [ERROR:flutter/shell/common/shell.cc(604)] Could not launch engine with configuration.

Permission in Android Manifest

 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
 <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
 <uses-permission android:name="android.permission.INTERNET"/>
 <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
Corgi answered 21/9, 2022 at 6:31 Comment(0)
C
11

This seems to be an issue across Flutter 3.3 which is breaking plugins running in isolates.

You need to annotate top level or static functions running in isolates with @pragma('vm:entry-point')

Like this

@pragma('vm:entry-point')
void locationCallback() {
  .......
  });

}

Corundum answered 21/9, 2022 at 6:52 Comment(2)
Yes, you are correct that the error was caused because of version 3.3.* I downgrade it to 3.0.* and It's working nowCorgi
I am using 3.19.4, still getting the issue and can't revert back to 3.3. (Crying)Cryology

© 2022 - 2024 — McMap. All rights reserved.