Skip to content

[Bug]: Location background service has not started correctly #1739

@ZTMIDGO

Description

@ZTMIDGO

Please check the following before submitting a new issue.

Please select affected platform(s)

  • Android
  • iOS
  • Linux
  • macOS
  • Web
  • Windows

Steps to reproduce

On android 15 (API 35)

Add permissions:
android.permission.ACCESS_FINE_LOCATION
android.permission.ACCESS_COARSE_LOCATION
android.permission.ACCESS_BACKGROUND_LOCATION
android.permission.FOREGROUND_SERVICE_LOCATION
android.permission.POST_NOTIFICATIONS

add geolocator: ^14.0.2

run Geolocator.checkPermission();

run Geolocator.getPositionStream

Expected results

Background Location

Actual results

Location background service has not started correctly

Code sample

Code sample
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  
  await Geolocator.checkPermission();

  LocationSettings locationSettings = AndroidSettings(
        accuracy: LocationAccuracy.best,
        distanceFilter: 100,
        forceLocationManager: true,
        intervalDuration: const Duration(seconds: 10),
        foregroundNotificationConfig: const ForegroundNotificationConfig(
          notificationText:
          "The app will continue to receive your location even when you aren't using it",
          notificationTitle: "Location",
          enableWakeLock: true,
          setOngoing: true,
        ),
  );

  StreamSubscription<Position> globalGeolocator = Geolocator.getPositionStream(locationSettings: locationSettings).listen((Position? position) async {});
  
  runApp(const MyApp());
}

Screenshots or video

Screenshots or video demonstration

[Upload media here]

Version

14.0.2

Flutter Doctor output

Doctor output
logcat:
D/FlutterGeolocator(32312): Creating service.
D/FlutterGeolocator(32312): Binding to location service.
I/flutter (22564): Another exception was thrown: Instance of 'DiagnosticsProperty<void>'
I/flutter (22564): Another exception was thrown: Instance of 'DiagnosticsProperty<void>'
E/FlutterGeolocator(32312): Location background service has not started correctly
D/FlutterGeolocator(17384): Flutter engine connected. Connected engine count 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions