Develop with the SDK

Last edit: 2023.02.23

Follow all instructions on this page to build your own Digital Cockpit application using the SDK source code.


Download the SDK source code

The SDK source code is available on GitHub. You can clone the sources with the following command:

git clone https://github.com/tomtom-international/tomtom-digital-cockpit-sdk-examples.git

Install the Java Development Kit

TomTom Digital Cockpit requires OpenJDK 11, which is a free and open-source implementation of the Java platform.

Linux

To install it, run the following command in a terminal:

sudo apt install openjdk-11-jdk

You might already have other versions of JDK installed. Verify this by running:

sudo update-java-alternatives -l

If you see the following output, then you only have OpenJDK and you are all set:

java-1.11.0-openjdk-amd64 1111 /usr/lib/jvm/java-1.11.0-openjdk-amd64

If you see multiple Java versions in the output, you need to make sure you have the correct one set as the default:

sudo update-java-alternatives -s java-1.11.0-openjdk-amd64

Then you can verify that the correct Java version is in use by running:

java --version

You should see output similar to this:

1openjdk 11.0.17 2022-10-18
2OpenJDK Runtime Environment (build 11.0.17+8-post-Ubuntu-1ubuntu220.04)
3OpenJDK 64-Bit Server VM (build 11.0.17+8-post-Ubuntu-1ubuntu220.04, mixed mode, sharing)
Mac

Adoptium Temurin JDK Java version 11 can easily be installed on Mac using Homebrew:

brew tap AdoptOpenJDK/openjdk
brew install --cask adoptopenjdk11

Then you can verify that the correct Java version is in use by running:

java --version

You should see output similar to this:

1openjdk 11.0.17 2022-10-18
2OpenJDK Runtime Environment Temurin-11.0.17+8 (build 11.0.17+8)
3OpenJDK 64-Bit Server VM Temurin-11.0.17+8 (build 11.0.17+8, mixed mode)
Windows

Select Windows, your CPU architecture, and JDK 11 from the dropdown menu.

Download and run the .msi installer.

Enable the Set JAVA_HOME variable if you intend to build from the command-line.

Then you can verify that the correct Java version is in use by running:

java -version

You should see output similar to this:

1openjdk version "11.0.13" 2021-10-19
2OpenJDK Runtime Environment Temurin-11.0.13+8 (build 11.0.13+8)
3OpenJDK 64-Bit Server VM Temurin-11.0.13+8 (build 11.0.13+8, mixed mode)

Configure Android Studio

Custom configuration of Android Studio is required to work with the Digital Cockpit SDK.

Install Android Studio

The minimum required version of Android Studio is Electric Eel | 2022.1.1.

Android Studio may automatically start building the project and report build errors, which is normal. Follow the remaining instructions on this page to build the project successfully.

Install Android SDK

Digital Cockpit runs on Android 11. The Android 11 SDK needs to be installed from the SDK Manager in Android Studio.

  • Navigate to Tools > SDK Manager.
  • Navigate to the SDK Platforms tab.
  • Find Android 11.0 (R).
  • Check the box next to that version.
  • Click Apply.

The Android 11 SDK will now be installed.

Configure the JDK

Android Studio needs to use the JDK you installed earlier.

Linux and Windows
  • Navigate to File > Settings > Build, Execution, Deployment > Build Tools > Gradle.
  • From the dropdown menu next to Gradle JDK select the OpenJDK version you installed earlier.
  • Click Apply.
Mac
  • Navigate to Android Studio > Preferences > Build, Execution, Deployment > Build Tools > Gradle
  • From the dropdown menu next to Gradle JDK select the OpenJDK version you installed earlier.
  • Click Apply.

Configure your credentials

After successful registration, you must make your received credentials available to Gradle so that it can access the necessary dependencies.

Linux and Mac

Navigate to your system's Gradle directory:

cd ~/.gradle

Create a gradle.properties file:

touch gradle.properties

Edit the gradle.properties file and add your credentials:

nexusUsername=<your-username>
nexusPassword=<your-password>
Windows

Navigate to your system's Gradle directory:

cd %USERPROFILE%\.gradle

Create a gradle.properties file:

notepad gradle.properties

Edit the gradle.properties file and add your credentials:

nexusUsername=<your-username>
nexusPassword=<your-password>

Build an APK

Now you can build your own APK from the SDK source files.

Linux and Mac

Run the following command from the root of the project:

./gradlew template_app:assembleRelease

You will find the generated APK in the following directory:

tomtom-digital-cockpit-sdk-examples/template/app/build/outputs/apk/release
Windows

Run the following command from the root of the project:

.\gradlew.bat template_app:assembleRelease

You will find the generated APK in the following directory:

tomtom-digital-cockpit-sdk-examples\template\app\build\outputs\apk\release

Run the application

You can run the APK you just generated on an emulator:


Have a look at the tutorials to explore what the Digital Cockpit SDK example code has to offer.