Project setup

VERSION 0.32.0
PUBLIC PREVIEW

Navigation SDK for Android is only available upon request. Contact us to get started.

This guide describes how you can set up your Android project to use the TomTom Navigation SDK. After completing the guide you should have an empty Android project that works using Navigation SDK dependencies.

  1. Install Android Studio if you don’t already have it.
  2. Create a new project or open an existing one. Make sure that the minimum SDK API level is set to at least 21 (Android 5.0 "Lollipop").
    1android {
    2 ...
    3 defaultConfig {
    4 ...
    5 minSdk 21
    6 ...
    7 }
    8 ...
    9}
  3. Make sure to use Gradle in your project. We are no longer supporting Maven. Contact us if your project is using Maven instead of Gradle.
  4. Add the following packaging options to the android block in the build.gradle file of your application module (app/build.gradle).
    1android {
    2 ...
    3 packagingOptions {
    4 jniLibs.pickFirsts.add("lib/**/libc++_shared.so")
    5 }
    6}

Gaining access

  1. Because the repository for Navigation SDK is private, you will need to contact us to get access.

  2. Once you have access, go to repositories.tomtom.com and log in with your account. Expand the user menu in the top-right corner, and select "Edit profile" → "Generate an Identity Token". Copy the generated token and use it to specify your credentials in your project gradle.properties file:

    • Replace user_name_placeholder with the login username or email you use for repositories.tomtom.com.
    • Replace identity_token_placeholder with the generated identity token.
    repositoryUsername=user_name_placeholder
    repositoryIdentityToken=identity_token_placeholder

Configuring project dependencies

  1. Add a maven block to your settings.gradle file to specify the credentials and the URI for repositories.tomtom.com.

    1dependencyResolutionManagement {
    2 repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    3 repositories {
    4 google()
    5 mavenCentral()
    6 maven {
    7 credentials {
    8 username = repositoryUsername
    9 password = repositoryIdentityToken
    10 }
    11 url = uri("https://repositories.tomtom.com/artifactory/maven")
    12 }
    13 }
    14}
  2. Verify that everything works as expected by adding a Navigation SDK dependency to the build.gradle file of your application module. For example, com.tomtom.sdk.navigation:navigation-online. Synchronize the project.

    1dependencies {
    2 def version = "0.32.0"
    3 implementation "com.tomtom.sdk.navigation:navigation-online:$version"
    4}
  3. Get your TomTom API key from the TomTom Developer Portal. To find out how, refer to the How to get a TomTom API key guide.

  4. Store the TomTom API key to a project property in your project gradle.properties file. Replace api_key_placeholder with the actual TomTom API key.

    tomtomApiKey=api_key_placeholder
  5. Map the TomTom API key property to a custom field of the gradle BuildConfig class in the build.gradle file of your application module. You should also enable the BuildConfig feature.

    1android {
    2 ...
    3 buildFeatures {
    4 buildConfig = true
    5 }
    6 buildTypes.each {
    7 it.buildConfigField 'String', 'TOMTOM_API_KEY', "\"$tomtomApiKey\""
    8 }
    9}

    To use the TomTom API key in your application code, it is sufficient to access the newly added BuildConfig field.

    val apiKey = BuildConfig.TOMTOM_API_KEY

Now that you’ve completed the project setup, here is what you can do next.

Build a simple navigation application

Use all the relevant Navigation SDK APIs and built-in UI components to build a navigation application:

Learn more

Here are some suggestions for other things you can do: