Getting started with the Google Navigation SDK

Build a basic in-app turn by turn navigation app for Android with the Google Navigation SDK.

Getting started with the Google Navigation SDK

In this blog post, we are getting hands on with the Google Navigation SDK (commonly known as the Nav SDK) by building a simple Android navigation app using starter code from the official Navigation SDK Code Lab. We’ll go over how to set up the Nav SDK, make sure your app has the right permissions and libraries, and get it to provide in-app driving directions to a preset destination. Future tutorials will show you how to let users set their destination address using a Place Autocomplete text box, customize the navigation interface with your branding, and adjust the position and visibility of key UI elements for better control.

Part 1: Google Navigation SDK standalone
Part 2: Getting started with the Google Navigation SDK (this article)
Part 3: Adding a Place Autocomplete text box to your Android app
Part 4: Creating a custom route on Google Maps for Android
Part 5: Styling the Navigation SDK with custom UI and branding
Part 6: Custom Google Maps markers on the navigation view
Part 7: Customize your vehicle icon with the Navigation SDK
Part 8: Using the Navigation SDK for multi waypoint navigation

About this Google Navigation SDK tutorial

This tutorial is intended for developers with general software development experience but who are not experts in Android mobile development or the Kotlin programming language. There are two ways to get the most out of this tutorial. If you already have a mobile app and want to use the Navigation SDK as a drop-in replacement for your existing in-app navigation system, go ahead and clone the nav_sdk_tutorial (coming soon!) repository, add your Google Maps API key to the local.defaults.properties and secrets.properties files and run the app in Android Studio. To understand the nuts and bolts of the Nav SDK, follow along line by line. If you get stuck at any point you can always refer to the commit history (coming soon) of nav_sdk_tutorial for guidance.

Afi Labs builds custom transportation and logistics management software. From route optimization, live tracking to proof of delivery and driver apps, we've got you covered!
👋 Say Hello!

Initial commit

To get hold of our starter code, clone the Codelab repo with git clone https://github.com/googlemaps-samples/codelab-navigation-101-android-kotlin.git.

Navigate to the /Starter directory and copy + paste its contents into a new folder called nav_sdk-afi_labs.

We'll be using this code base as the starting point for our navigation app. Download Android Studio and open the /nav_sdk-afi_labs folder. Run the app by pressing the ▶️ button on the top nav bar. You should see an empty app running in the simulator. This means that your computer has everything it needs to run an Android app locally.

Commit 292c619: Initial commit

Setup SDK: Add dependencies

Open the app/build.gradle.kts file and add the line:

api("com.google.android.libraries.navigation:navigation:5.2.3")

to the dependencies object. This line adds a dependency on the com.google.android.libraries.navigation:navigation library (version 5.2.3) and ensures it is downloaded and included in your project during the build process.

Gradle is an open-source build automation tool widely used in the Java and Kotlin development communities. The line above instructs Gradle to retrieve the Google Navigation SDK from Maven and include it automatically during the build process.

Setup SDK: Config Navigation SDK API key

Next, we are going to securely authenticate with the Google Maps server using the Navigation SDK enabled API key we created in the previous section.