To set up and configure a Google Cloud console project to use the Driver SDK for
Android, follow these steps.

1. [Set up your mobile app project](https://developers.google.com/maps/documentation/mobility/driver-sdk/on-demand/android/configure-project.md.txt#auth-project).
2. [Add the Driver SDK to your app](https://developers.google.com/maps/documentation/mobility/driver-sdk/on-demand/android/configure-project.md.txt#add-sdk).
3. [Add the API key to your app](https://developers.google.com/maps/documentation/mobility/driver-sdk/on-demand/android/configure-project.md.txt#add-key).
4. [Include the required attributions in your app](https://developers.google.com/maps/documentation/mobility/driver-sdk/on-demand/android/configure-project.md.txt#include-attributions).

For more details on each step, see the following sections.

> [!NOTE]
> **Note:** Your app must target `minSdkVersion` 23 or higher.

## Set up your mobile app project

This section describes how to configure your mobile app project for the Driver
SDK.

To configure your mobile app project, follow these steps:

1. If you don't have a Google Cloud console development project and an API key for your mobility project, you need to set one up. For more information, see [Create your Fleet Engine project](https://developers.google.com/maps/documentation/mobility/fleet-engine/essentials/set-up-fleet/create-project.md.txt).
2. In the Google Cloud console, select the same Google Cloud console project and API key that you are using for Fleet Engine.
3. Select **APIs \& Services** and search for and enable the Maps SDK for Android.

## Add the Driver SDK to your app

The Driver SDK is available from the Google Maven repository. The repository
includes the SDK's Project Object Model (.pom) files and Javadocs.

To add the Driver SDK to your app, add the Driver SDK and Navigation SDK
dependencies to your Gradle or Maven configuration.

> [!NOTE]
> **Note:** The Driver SDK depends on the Navigation SDK. Set your dependency to an **explicitly defined** version of the Navigation SDK, as shown in this example. Otherwise, omit the example code block to enable the project to always download the latest version of the Navigation SDK within the major release version. The combined behaviors of the latest versions of Driver SDK and Navigation SDK have undergone rigorous testing before their releases.

In the following example, substitute `VERSION_NUMBER` with the selected version
of the Driver SDK.

### Gradle

Add the following to your `build.gradle`:

```groovy
dependencies {
...
implementation 'com.google.android.libraries.mapsplatform.transportation:transportation-driver:VERSION_NUMBER'
implementation 'com.google.android.libraries.navigation:navigation:5.0.0'
}
```

### Maven

Add the following to your `pom.xml`:

```xml
<dependencies>
  ...
  <dependency>
    <groupId>com.google.android.libraries.mapsplatform.transportation.driver</groupId>
    <artifactId>transportation-driver</artifactId>
    <version>VERSION_NUMBER</version>
  </dependency>
  <dependency>
    <groupId>com.google.android.libraries.navigation</groupId>
    <artifactId>navigation</artifactId>
    <version>5.0.0</version>
  </dependency>
</dependencies>
```

## Add the API key to your app

Once you have added the Driver SDK to your app, add the API key. You must use
the project API key you obtained when you set up your development project. For
more details, see [Set up your mobile app project](https://developers.google.com/maps/documentation/mobility/driver-sdk/on-demand/android/configure-project.md.txt#auth-project).

This section describes how to store your API key so that it can be more securely
referenced by your app. For more information on API key security best practices,
see the Google Maps Platform article on [API security best practices](https://developers.google.com/maps/api-security-best-practices.md.txt#restrict_apikey).

> [!IMPORTANT]
> **Important:** Don't check your API key into your version control system. Instead, store it in the `local.properties` file, which is located in the root directory of your project. For more information about the `local.properties` file, see [Gradle properties files](https://developer.android.com/studio/build#properties-files).

To streamline this task, you can use the GitHub documentation
[Secrets Gradle Plugin for Android](https://github.com/google/secrets-gradle-plugin).

To install the plugin and store your API key, follow these steps:

1. Open your root-level `build.gradle` file and add the following code to the
   `dependencies` element under `buildscript`.

   ### Groovy

   ```groovy
   buildscript {
         dependencies {
             // ...
             classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.0"
         }
   }
   ```

   ### Kotlin

   ```kotlin
   buildscript {
       dependencies {
           // ...
           classpath("com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.0")
       }
   }
   ```
2. Open your app-level `build.gradle` file and add the following code to the
   `plugins` element.

   ### Groovy

   ```groovy
   id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
   ```

   ### Kotlin

   ```kotlin
   id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin")
   ```
3. If you use Android Studio, sync your project with Gradle. For details, see
   [Sync your project with Gradle](https://developer.android.com/studio/build#sync-files).

4. Open the `local.properties` in your project level directory, and then add
   the following code. Replace `YOUR_API_KEY` with your API key.

   MAPS_API_KEY=<var translate="no">YOUR_API_KEY</var>
5. In your `AndroidManifest.xml` file, go to `com.google.android.geo.API_KEY`
   and update the `android:value` attribute as follows:

```html
       <meta-data
           android:name="com.google.android.geo.API_KEY"
           android:value="${MAPS_API_KEY}" />
```

The following example shows a complete manifest for a sample app:

```html
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.driverapidemo" >
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
        <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:supportsRtl="true"
            android:theme="@style/_AppTheme" >

            <meta-data
                android:name="com.google.android.geo.API_KEY"
                android:value="${MAPS_API_KEY}" />

            <activity android:name=".MainActivity" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>
    </manifest>
```

> [!NOTE]
> **Note:** For the best navigation experience, the driver should grant the following permissions: `android.permission.ACCESS_COARSE_LOCATION` and `android.permission.ACCESS_FINE_LOCATION`. Make sure to request both of those at runtime within the app.

## Include the required attributions in your app

If you use the Driver SDK in your app, you must include attribution text and
open source licenses as part of your app's legal notices section. It's best to
include the attributions as an independent menu item or as part of an **About**
menu item.

You can find the license information in the "third_party_licenses.txt" file in
the unarchived AAR file.

Refer to [Include open source notices](https://developers.google.com/android/guides/opensource.md.txt) on how to
include open source notices.

## What's next

[Declare dependencies](https://developers.google.com/maps/documentation/mobility/driver-sdk/on-demand/android/dependencies.md.txt)