SDK for Android Developer's Guide

Run the Sample Application

This tutorial contains instructions on how to run the basic sample application to render a map on an Android device. This tutorial assumes that you are using the Android Studio development environment and a supported Android device. For more details, see System Requirements.

Development tasks for this basic application include:

Open the Sample Project in Android Studio

The next task before running the sample HERE SDK project is to locate the project folder and open it in Android Studio as follows:

  1. In the Welcome to Android Studio dialogue box select Open an existing Android Studio project.
  2. In the Open File or Project dialogue box select the BasicMapSolution folder from your file system and click OK. The BasicMapSolution folder is located at HERE-sdk.zip/HERE-sdk/tutorial/.
  3. After completing these steps the main Android Studio project window should appear with "Error: Failed to resolve: :HERE-sdk:" in the Messages pane.

Import the HERE SDK Android Archive

The SDK for Android library is shipped as an Android Archive (.AAR) file. You can import this library by doing the following:

  1. On the View menu click Tool Windows > Project.
  2. A few tabs are available in this tool window. Select the Project tab to show a file system view of the application structure.
  3. Set Project's view to Project instead of Android.
  4. Right-click on the app folder and select New > Directory to create a new folder. Use libs as the new folder name.
  5. In your operating system's file system navigate to the extracted HERE SDK directory. Copy the HERE-sdk.aar file and paste it into the newly created libs directory.
  6. Open the build.gradle file under the app folder and ensure the following entry is present:
    dependencies {
      implementation files('libs/HERE-sdk.aar')
      // Depending on your specific project configuration you may have other entries here.
    }
    
  7. Optional: To enable quick Javadoc reference within your Android Studio environment, scroll down to the External Libraries section, right-click on HERE-sdk, and then select Library Properties. Click the + button and locate HERE-sdk-javadoc.jar from HERE SDK package.
Note: You can also import HERE-sdk.aar by using the menu, selecting File > Project Structure..., and clicking the "+" button. If you use this method, ensure that HERE-sdk is listed properly under the app Module Dependencies.
Figure 1. Location of the .AAR file

Add Credentials

This sample application is not shipped with a set of required HERE SDK credentials. Typically, before developing a new HERE SDK application, you need to acquire a set of credentials by registering your application on https://developer.here.com. Each application requires a unique set of credentials. When you register your app, the registered bundle identifier must match the applicationId in your project's build.gradle. For the full authentication story, see the Identity & Access Management Developer Guide.

Since this sample app has the package name com.here.android.tutorial by default, you can generate a set of app credentials on https://developer.here.com using the same package name and add them to the app.

You can add credentials to your app by opening the BasicMapSolution/app/src/main/AndroidManifest.xml file and modifying the following <meta-data> tags:

  • <meta-data android:name="com.here.android.maps.appid" android:value="{YOUR_APP_ID}"/>
  • <meta-data android:name="com.here.android.maps.apptoken" android:value="{YOUR_APP_CODE}"/>
  • <meta-data android:name="com.here.android.maps.license.key" android:value="{YOUR_LICENSE_KEY}"/>"/>

Run the Project

You can run your simple application by pressing the key combination Shift + F10 (or Ctrl + R on macOS) from within Android Studio. The application renders a map retrieved from HERE servers. When you are running your application on a device, make sure data connection is enabled.

Note: For detailed instructions on how to create a new HERE SDK app, see Create a Simple App Using HERE SDK.