-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Is there an existing issue for this?
- I have searched the existing issues
Description of the bug
I am experiencing a crash in my Flutter app when using the google_navigation_flutter package. The crash is reported in Crashlytics with the following error:
Fatal Exception: android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException
Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{3552ccf u0 com.getpackage.courier/com.google.android.libraries.geo.navcore.service.base.NavigationService c:com.getpackage.courier}
This issue occurs when attempting to start the navigation service.
Flutter version
Flutter 3.29.2 • channel stable
Package version
google_navigation_flutter: ^0.6.1
Native SDK versions
- I haven't changed the version of the native SDKs
Flutter Doctor Output
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.29.2, on macOS 14.5 23F79
darwin-x64, locale en-IL)
[✓] Android toolchain - develop for Android devices (Android
SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] IntelliJ IDEA Community Edition (version 2022.2.1)
[✓] VS Code (version 1.101.2)
[✓] Connected device (2 available)
! Error: Browsing on the local area network for liat’s
iPhone. Ensure the device is unlocked and attached with
a cable or associated with the same local area network
as this Mac.
The device must be opted into Developer Mode to connect
wirelessly. (code -27)
! Error: Browsing on the local area network for ה-iPhone
של GetPackage. Ensure the device is unlocked and
attached with a cable or associated with the same local
area network as this Mac.
The device must be opted into Developer Mode to connect
wirelessly. (code -27)
[✓] Network resources
• No issues found!
Steps to reproduce
- In this environment:
Flutter version: 3.29.2 • channel stable
google_navigation_flutter version: ^0.6.1 - With this configuration:
Android device running Android 15
Navigation service initialized as per the package documentation. - Run the app and start navigation.
- Observe the crash in Crashlytics.
Expected vs Actual Behavior
Expected: The navigation service should start without any issues.
Actual: The app crashes with the error:
Fatal Exception: android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException
Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{3552ccf u0 com.getpackage.courier/com.google.android.libraries.geo.navcore.service.base.NavigationService c:com.getpackage.courier}
Code Sample
void _initializeNavigation() async {
_onArrivalSubscription?.cancel();
_onArrivalSubscription = null;
_stepInfoSubscription?.cancel();
_stepInfoSubscription = null;
_onArrivalSubscription =
GoogleMapsNavigator.setOnArrivalListener(onArrivedToDestination);
if (Platform.isAndroid) {
} else {
GoogleMapsNavigator.allowBackgroundLocationUpdates(true);
}
_stepInfoSubscription = GoogleMapsNavigator.setNavInfoListener(
(e) {
stepInfoChanged(e);
},
numNextStepsToPreview: 100,
);
var avoidTolls = IOC<SharedPreferences>().getBool('avoidTolls') ?? false;
var res = await GoogleMapsNavigator.setDestinations(
Destinations(
routingOptions:
RoutingOptions(travelMode: travelMode, avoidTolls: avoidTolls),
displayOptions: NavigationDisplayOptions(),
waypoints: [
NavigationWaypoint(
title: activePoints.firstOrNull?.address?.addressLine1 ?? '',
target: LatLng(
latitude: activePoints.firstOrNull?.location?.latitude ?? 0,
longitude:
activePoints.firstOrNull?.location?.longitude ?? 0))
]),
);
if (res == NavigationRouteStatus.statusOk) {
GoogleMapsNavigator.setAudioGuidance(NavigationAudioGuidanceSettings(
guidanceType: _navigationWithSound
? NavigationAudioGuidanceType.alertsAndGuidance
: NavigationAudioGuidanceType.silent));
await GoogleMapsNavigator.startGuidance();
var useNavigationSimulator =
IOC<SharedPreferences>().getBool('useNavigationSimulator') ?? false;
var flavor = const String.fromEnvironment('app.flavor');
if (useNavigationSimulator && flavor != 'prod') {
await GoogleMapsNavigator.simulator
.simulateLocationsAlongExistingRouteWithOptions(
SimulationOptions(speedMultiplier: 10));
}
}
}
Additional Context
The issue seems to be related to the startForegroundService() call in the native Android code.
The crash occurs intermittently but is reported in Crashlytics.
No additional logs are available beyond the Crashlytics report.