How to use a Shared HERE SDK Module Across SDK example projects

How to use a Shared HERE SDK Module Across SDK example projects
===================================================================

This guide explains how to integrate a shared HERE SDK module (shared-sdk-module) into multiple HERE Android example projects. It centralizes the HERE SDK AAR file and credential configuration, so all projects can reuse them without duplication.

---

Prerequisites
-----------------

Unzip the provided shared-sdk-module.zip into the parent directory that contains all HERE SDK sample projects:

<br />heresdk-navigate-android-examples-4.21.5.0/├── shared-sdk-module/ ← This is where you extract it<br />



Do not place it inside individual projects.

1. Folder Structure
-----------------------

Make sure your project directory looks like this:

<br />heresdk-navigate-android-examples-4.21.5.0/├── shared-sdk-module/ ← Place the shared module here├── HelloMap/├── Navigation/├── ...├── gradlew.bat ← You will run this├── build.gradle├── shared-sdk-config.gradle└── update-projects.gradle <br /> <br />![](https://files.readme.io/1b3884a94372dac4a597a1158af2c8a13bae09a934f0e73daf1acb3d15c57d99-Pasted_image1_b3e0da5b47753290503798d3616d4378.png)<br />

2. Add HERE SDK AAR to the Shared Module
--------------------------------------------

Copy your HERE SDK .aar file into the following location:

<br />shared-sdk-module/libs/heresdk-.aar<br />

Example:

<br />shared-sdk-module/libs/heresdk-4.21.5.0.aar <br /> <br />![](https://files.readme.io/561efeb1cf11881a9cf833e001a2098ca53ba06192c480bd470985799b6a049e-Pasted_image3_3be01e5b47753290503798d3616d43d7.png)<br />

---

3. Configure Credentials
----------------------------

Edit the file:

<br />shared-sdk-module/gradle.properties<br />

Add your HERE credentials:

<br />HERE_ACCESS_KEY_ID=your_access_key_idHERE_ACCESS_KEY_SECRET=your_access_key_secret <br /> <br />![](https://files.readme.io/cb393aef0c02e42ada19f9a67fe62bf93a6e52a5facefd211be2040ab65a37de-Pasted_image7_3fe01e5b47753290503798d3616d43dd.png)<br />

In shared-sdk-module/build.gradle, ensure the following lines exist in defaultConfig:

<br />buildConfigField "String", "HERE_ACCESS_KEY_ID", "\"${HERE_ACCESS_KEY_ID}\""buildConfigField "String", "HERE_ACCESS_KEY_SECRET", "\"${HERE_ACCESS_KEY_SECRET}\""<br />

Also make sure buildConfig is enabled:

<br />buildFeatures { buildConfig = true} <br /> <br />![](https://files.readme.io/f79ee7bf67f33e58b0180787049b2ae2ce4be3885bce6aaacdaa0d4dcfef3083-Pasted_image6_f3e01e5b47753290503798d3616d43dc.png)<br />

---

4. Run Batch Setup from the Parent Directory
------------------------------------------------

Open a terminal in the parent folder (heresdk-navigate-android-examples) and run:

<br />gradlew.bat setupAllProjects on Windows<br />

or

<br />gradlew setupAllProjects on Mac.<br />



This script should automatically:

Add shared-sdk-module to each project's settings.gradle
Insert implementation project(':shared-sdk-module') into each app/build.gradle
Replace hardcoded credentials in Java code with:

<br />String accessKeyID = com.example.sharedsdkmodule.BuildConfig.HERE_ACCESS_KEY_ID;String accessKeySecret = com.example.sharedsdkmodule.BuildConfig.HERE_ACCESS_KEY_SECRET;<br />

Make sure your script performs these tasks. If needed, I can help improve it.



---

5. Open Projects in Android Studio
--------------------------------------

After running setupAllProjects, you can open any individual project (e.g., HelloMap/) in Android Studio and build it normally. The project will now use the shared SDK module and credentials.

Make sure running File\Sync Project with Gradle Files before rebuild.



Then you shall be able to run different samples without reconfiguring them repeatedly :)



---

6. Notes
------------

Do not open the shared module or subproject directly before running the batch setup.
* Keep the credentials in gradle.properties, but avoid uploading this file to a public repository.