Baseflow / Baseflow/flutter-geolocator
[Bug]: Location background service has not started correctly
- Dominant language
- Dart
- Stars
- 1.3k
- Forks
- 803
- Avg merge
- 8h 16m
- Merged PRs (30d)
- 1
Description
### Please check the following before submitting a new issue.
- [x] I have searched the [existing issues](https://github.com/baseflow/flutter-geolocator/issues).
- [x] I have carefully [read the documentation](https://github.com/Baseflow/flutter-geolocator/blob/main/geolocator/README.md) and verified I have added the required platform specific configuration.
### Please select affected platform(s)
- [x] 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
```dart
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 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
```console
logcat:
D/FlutterGeolocator(32312): Creating service.
D/FlutterGeolocator(32312): Binding to location service.
I/flutter (22564): Another exception was thrown: Instance of 'DiagnosticsProperty'
I/flutter (22564): Another exception was thrown: Instance of 'DiagnosticsProperty'
E/FlutterGeolocator(32312): Location background service has not started correctly
D/FlutterGeolocator(17384): Flutter engine connected. Connected engine count 1
```
Contributor guide
Research direction
Start by reproducing the report on Android 15 with the provided Dart sample, especially Geolocator.checkPermission and Geolocator.getPositionStream, while reviewing the shown logcat output. Done means the foreground location service starts correctly and the position stream continues receiving background updates without the reported error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, dart
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100