Loading...
Loading...
Upgrades an Android app (Java or Kotlin) that uses the Navigation SDK for Android (com.google.android.libraries.navigation) from 7.x to 8.0. Covers the AGP 9.0.1 / Gradle 9.1.0 toolchain floor, targetSdk 37 and the Play Location Purpose Declaration, removed transitive dependencies (kotlin-reflect, Glide), androidx.car.app 1.3.0, and the 8.0 API changes: removed DisplayOptions.showTrafficLights / showStopSigns and onGpsAvailabilityUpdate, new RouteStatus.ROUTING_TIMEOUT, terrain map type during navigation, and deprecations of ListenableResultFuture, SupportNavigationFragment, setAudioGuidance, FollowMyLocationOptions, and NavigationTransactionRecorder Waypoint overloads. Use when upgrading NavSDK to 8.0, fixing a build that broke after the bump, or auditing what 8.0 changes for an app. Don't use for iOS.
npx skill4agent add googlemaps/agent-skills migrating-navsdk-7x-to-8x-androidcom.google.android.libraries.navigation.*com.google.android.libraries.navigation:navigationNavigationApi.getNavigator(...)Navigator.RouteStatusenumintcom.google.android.libraries.navigation:navigation:<version>build.gradlebuild.gradle.ktsandroidx.car.appval pending = navigator.setDestination(...)ListenableResultFuturesetOnResultListenergrep -rnE "showTrafficLights|showStopSigns|onGpsAvailabilityUpdate|ListenableResultFuture|setOnResultListener|SupportNavigationFragment|setAudioGuidance\(|simulateLocationsAlongNewRoute|MAP_TYPE_TERRAIN|RouteStatus|getNavigator|NavigationTransactionRecorder|FollowMyLocationOptions|header[A-Za-z]*(TypefacePath|TextSize)|kotlin-reflect|kotlin\.reflect|bumptech\.glide|androidx\.car\.app" \
--include=*.java --include=*.kt --include=*.xml --include=*.gradle --include=*.kts --include=*.pro .minAndroidGradlePluginVersion=9.0.1compileSdktargetSdkdesugar_jdk_libs_niocom.google.gms:google-servicesapplicationVariantsandroid.suppressUnsupportedCompileSdk=37.0gradle.properties[!CAUTION] Do not tell developers they need JDK 25. JDK 25 is the internal toolchain used to build NavSDK itself. For a host app on AGP 9, JDK 17 is the minimum Gradle runtime and JDK 21 LTS is recommended.
package=kotlinOptionsdexOptionsorg.jetbrains.kotlin.multiplatformkotlin-tooling-agp9-migrationACCESS_FINE_LOCATIONorg.jetbrains.kotlin:kotlin-reflectcom.github.bumptech.glide:glidecom.github.bumptech.glide:okhttp3-integrationkotlin.reflect.*::classKClasscom.bumptech.glide.*kotlin-reflectkotlin.reflect.*com.bumptech.glide.*annotationProcessorkaptkspandroidx.car.appandroidx.car.app:appandroidx.car.app:app-projectedDisplayOptions.showTrafficLights(...)showStopSigns(...)RoadSnappedLocationProvider.GpsAvailabilityEnhancedLocationListener.onGpsAvailabilityUpdate(boolean)onGpsAvailabilityChange(GpsAvailabilityChangeEvent)@OverrideNavigator.RouteStatus.ROUTING_TIMEOUTGoogleMap.MAP_TYPE_TERRAINMAP_TYPE_NORMALStylingOptionsParcelableCREATORwriteToParcelStylingOptionsBundleIntentNavigationApi.ErrorCode.NETWORK_ERRORgetNavigator(Application, ...)ActivityApplicationonErrorNETWORK_ERRORTERMS_NOT_ACCEPTEDonErrorNETWORK_ERRORgetNavigatorNETWORK_ERRORROUTING_TIMEOUTwhen (status)ROUTING_TIMEOUTelseswitch->switchval message = when (routeStatus) {
Navigator.RouteStatus.OK -> null
Navigator.RouteStatus.ROUTING_TIMEOUT -> "Route calculation timed out. Try again."
Navigator.RouteStatus.NETWORK_ERROR -> "Network error. Check your connection."
// ...existing branches...
else -> "Could not calculate a route ($routeStatus)."
}StylingOptionsFollowMyLocationOptionsListenableResultFuture<RouteStatus>Navigator.setDestination(s)(...)RouteDescriptionLoadCallbackvoidSimulator.simulateLocationsAlongNewRoute(...)ListenableResultFutureRouteDescriptionLoadCallbackSupportNavigationFragmentNavigationFragmentnewInstance()newInstance(GoogleMapOptions)NavigationTransactionRecorder.pickup(Waypoint, List)dropoff(Waypoint, List)pickup(List)dropoff(List)Navigator.setAudioGuidance(@AudioGuidance int)setAudioGuidanceSettings(AudioGuidanceSettings)StylingOptionsheader*TypefacePathheader*TextSizeGoogleMap.followMyLocation(int, FollowMyLocationOptions)FollowMyLocationOptionscom.google.android.gms.maps.modelfollowMyLocation(int)ListenableResultFutureRouteDescriptionLoadCallbackRouteDescriptionLoadCallbackcom.google.android.libraries.navigation.RouteDescriptionLoadCallbackonRouteDescription(RouteDescription)RouteDescription.getRouteStatus()Navigator.RouteStatus// Before (deprecated in 8.0)
ListenableResultFuture<Navigator.RouteStatus> future = navigator.setDestination(waypoint);
future.setOnResultListener(status -> {
if (status == Navigator.RouteStatus.OK) {
navigator.startGuidance();
}
});
// After
navigator.setDestination(
waypoint,
routeDescription -> {
if (routeDescription.getRouteStatus() == Navigator.RouteStatus.OK) {
navigator.startGuidance();
}
});navigator.setDestination(waypoint) { routeDescription ->
if (routeDescription.routeStatus == Navigator.RouteStatus.OK) {
navigator.startGuidance()
}
}setDestinationsetDestinationsRoutingOptionsDisplayOptionsCustomRoutesOptionsSupportNavigationFragmentNavigationFragmentandroid:name="..."class="..."<fragment>FragmentContainerView<fragment
android:id="@+id/navigation_fragment"
android:name="com.google.android.libraries.navigation.NavigationFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />NavigationFragmentFragmentSupportNavigationFragmentsupportFragmentManager(SupportNavigationFragment) getSupportFragmentManager().findFragmentById(...)instanceofisSupportNavigationFragment()SupportNavigationFragment.newInstance(...)[SupportNavigationFragment]setAudioGuidance(int)setAudioGuidanceSettings(...)AudioGuidanceSettings.builder()GuidanceMode.VOICE_ALERTS_AND_GUIDANCEVolumeLevel.NORMALNavigator.AudioGuidanceAudioGuidanceSettings.BuilderSILENTsetGuidanceMode(GuidanceMode.SILENT)VOICE_ALERTS_ONLYsetGuidanceMode(GuidanceMode.VOICE_ALERTS_ONLY)VOICE_ALERTS_AND_GUIDANCEsetGuidanceMode(GuidanceMode.VOICE_ALERTS_AND_GUIDANCE)VIBRATIONsetVibrationEnabled(true)setVibrationEnabled(false)BLUETOOTH_AUDIOsetBluetoothAudioEnabled(true)setBluetoothAudioEnabled(false)// Before: navigator.setAudioGuidance(
// Navigator.AudioGuidance.VOICE_ALERTS_AND_GUIDANCE | Navigator.AudioGuidance.BLUETOOTH_AUDIO);
navigator.setAudioGuidanceSettings(
AudioGuidanceSettings.builder()
.setGuidanceMode(AudioGuidanceSettings.GuidanceMode.VOICE_ALERTS_AND_GUIDANCE)
.setBluetoothAudioEnabled(true)
.setVibrationEnabled(false) // VIBRATION was not in the old bitmask
.build());w:options.compilerArgs += ["-Xlint:deprecation"]tasks.withType(JavaCompile)setTrafficIncidentCardsEnabled(false)NavigationViewNavigationFragmentcompileSdktargetSdkcom.google.android.libraries.navigation.*NavigationApi.getNavigator(...)RouteStatusshowTrafficLightsshowStopSignsonGpsAvailabilityUpdateRouteStatusROUTING_TIMEOUTRouteStatus.NETWORK_ERRORgetNavigatoronErrorErrorCode.NETWORK_ERRORgetNavigator(Application, ...)kotlin-reflectandroidx.car.appStylingOptionsSupportNavigationFragment