Navigation SDK is currently available only to select customers. Contact sales to learn more.

Try the demo

Stay organized with collections Save and categorize content based on your preferences.

By integrating the Navigation SDK for Android, your app can go beyond linking to an external map view. With Google Maps navigation, your app can offer dynamic retrieval and single-look reporting of data about a driver's journey.

This guide presents you with an Android Studio project, shows you how to integrate the Navigation SDK, and then shows you how to run the demo applications.

The Navigation SDK is a static library (.aar) that gives you control over the appearance and audio for navigation in your app. For details about the library, open Navigation SDK reference (Javadoc) in a separate window.

Get ready

To get started with the Navigation SDK, be sure to have the following items.

  • A Google Maps Platform representative for access to the following:

    • An API key provisioned for use with Navigation SDK. You need to provide your projectID which you can find in the Google Cloud Console main dashboard, under the project name.
    • The SDK artifact

      • Ensure that your project is configured to use Maven for the Navigation SDK.
      • If you cannot use Maven, you can download the zipped artifact from the shared Google Drive. The static library file is the .aar in the libs/ directory containing the Navigation SDK as an AAR bundle.
    • One or more of the demo apps

  • Android Studio, the recommended development environment for building an app with the Navigation SDK. This documentation is designed for people familiar with Android development and object-oriented programming concepts. You should also be familiar with Google Maps from a user's point of view.

Get the Demo apps

As of Navigation SDK for Android v4.1, the following demo apps let you test out features in the SDK. They are both available in the shared Google Drive to download.

  • GoogleNavigation demo: showcases the integration of API behaviors and views as they pertain to the user's experience while in a guided-navigation session.

  • GoogleMap demo: showcases individual behaviors of the GoogleMap interface to customize the feel and presentation of maps.

A note on using Maven

The demo apps are configured to download the SDK artifact from the remote Maven repository, using the Artifact Registry plugin in Gradle. Make sure to follow the project configuration instructions to gain access to the SDK.

Alternatively, if you still want to use the raw AAR bundle in your project, you can add it to your project under the libs directory. You'd then need to remove all references to the artifactregistry plugin and the respective remote repository, and declare the following AAR dependency in your app-level build.gradle:

  api(name: 'google_navigation', ext: 'aar')

The GoogleNavigation demo

The latest GoogleNavigation demo is available at the root of the shared Google Drive. Previous versions of the app exist in the "Archive." For versions prior to 4.1, the app is bundled alongside the AAR in the same zip file.

Building

  1. In Android Studio, import the demo app and allow Gradle to run.

  2. Open main/res/values/strings.xml and update the value of the maps_api_key property:

    <resources>
      ...
      <string name="maps_api_key" translatable="false">YOUR_API_KEY</string>
    </resources>
    
  3. Click build and examine the SDK implementation details.

    • In the java class, note the implementation code.

    • In the layout xml, note the layout design and text.

    • In the build.gradle file, note the SDK in the dependencies.

Running

  1. Connect an Android device to your computer or use an emulator.

    • Android device Refer to the instructions to enable developer options on your Android device and configure your system to detect the device.
    • Emulator Use the Android Virtual Device (AVD) Manager to configure a virtual device. When choosing an emulator, make sure you pick an image that includes the Google APIs.
  2. In Android Studio, click the Run menu option (or the play button icon); and then choose a deployment target.

When built and launched, the app presents the user with a landing page of a list of options.

New adopters of the NavSDK will likely find these two options to be the most useful.

Option 1: NavViewActivity showcases behaviors using the NavigationView in conjunction with the Navigator.

Option 2: The second option, titled NavFragmentActivity, showcases behaviors using the SupportNavigationFragment alongside the Navigator.

When you click one of these options, you'll be presented with the following:

  • the navigation UI
  • a "Set Destination" button in the app's menu
  • an overlay that you can interact with to dynamically invoke methods on the API
  • an overflow menu with more options

To get started, click Set Destination and pick an address. The app then simulates a trip from your current location to that address. Use the control panels overlay to see what happens when you call an API. For instance, you can click View Methods to try forcing the SDK into night-mode to see what it looks like.

SwappingMapAndNavActivity option

The SwappingMapAndNavActivity showcases the following common patterns:

The GoogleMap demo

The latest GoogleNavigation demo is available at the root of the shared Google Drive. Previous versions of the app exist in the "Archive."

Building

  1. In Android Studio, import the demo app and allow Gradle to run.

  2. Open AndroidManifest.xml and update the value of the com.google.android.geo.API_KEY property:

      <meta-data android:name="com.google.android.geo.API_KEY" android:value="YOUR_API_KEY"/>
    
  3. Click build and examine the SDK implementation details.

    • In the java class, note the implementation code.

    • In the layout xml, note the layout design and text.

    • In the build.gradle file, note the SDK in the dependencies.

Running

  1. Connect an Android device to your computer or use an emulator.

    • Android device Refer to the instructions to enable developer options on your Android device and configure your system to detect the device.
    • Emulator Use the Android Virtual Device (AVD) Manager to configure a virtual device. When choosing an emulator, make sure you pick an image that includes the Google APIs.
  2. In Android Studio, click the Run menu option (or the play button icon); and then, choose a deployment target.

When built and launched, the app presents the user with a landing page of a list of demos. Previous users of the Maps API on Android will find this presentation pattern, and the corresponding structure of the source code, familiar.

This is because the GoogleMap demo is designed to be similar to the Maps API demo app. The primary difference is that we include a toggle to let the user choose which view class they'd like to test-run a demo on: NavigationView or MapView, where applicable.

We generally encourage adopters to use the NavigationView, but want to give you the flexibility to try these behaviors on both versions in our sampleapp and choose whichever works for you. you. For example, it may still be necessary to use a MapView in situations where you are using a third-party library that expects to interact with that class.