Skip to main content

Installation

To start developing your application using the Mapbox Java SDK, you'll need to first decide which installation method works for you. The SDK is fully compatible with Android using Gradle and can also be included in a generic Java project using either Gradle or Maven. All the dependencies are served from Mapbox's maven repository, which requires some additional configuration.

Installation with Gradle

  1. Start Android Studio.
  2. Open your project's settings.gradle file.
  3. Add the Mapbox maven repository to the repositories block.
settings.gradle
dependencyResolutionManagement {
repositories {
...
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
}
}
}
  1. Open your project's app-level build.gradle file.
  2. Make sure that your project's minSdkVersion is API 14 or higher.
  3. In the dependencies block, add a new implementation dependency for each Java SDK package you want in your project, as shown below.
  4. Click Sync Project with Gradle Files near the toolbar in Android Studio.
build.gradle
dependencies {
...
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-geojson:7.3.1'
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:7.3.1'
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:7.3.1'
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-core:7.3.1'

implementation 'androidx.annotation:annotation:1.0.0'
}

Android's 64K method count limit
If your project is close or exceeds the 64K method count limit, you can mitigate this problem by selectively compiling only the specific Mapbox Android Service APIs you are using in your project.

Installation with Maven

If your project is using Maven instead of Gradle, you can add the dependencies inside your project's POM.xml file.

Add the Mapbox maven repository

Add the Mapbox maven repository to using a repository tag.

POM.xml
<project>
...
<repositories>
<repository>
<id>mapbox-repo</id>
<url>https://api.mapbox.com/downloads/v2/releases/maven</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
...
</project>

Add Mapbox Java SDK packages

Add a dependency tag, including the groupId, artifactId, and version for each package you want to use.

POM.xml
<project>
...
<dependencies>
...
<dependency>
<groupId>com.mapbox.mapboxsdk</groupId>
<artifactId>mapbox-sdk-geojson</artifactId>
<version>7.3.1</version>
</dependency>

<dependency>
<groupId>com.mapbox.mapboxsdk</groupId>
<artifactId>mapbox-sdk-services</artifactId>
<version>7.3.1</version>
</dependency>

<dependency>
<groupId>com.mapbox.mapboxsdk</groupId>
<artifactId>mapbox-sdk-turf</artifactId>
<version>7.3.1</version>
</dependency>

<dependency>
<groupId>com.mapbox.mapboxsdk</groupId>
<artifactId>mapbox-sdk-core</artifactId>
<version>7.3.1</version>
</dependency>
...
</dependencies>
...
</project>

Import and use the Java SDK

You can now import the Java SDK's modules and use them in your java project.

Explore each module's guides to learn key concepts and get usable code snippets:

Explore the API Reference to get a better understanding of all the available classes and methods.

For more inspiration and code snippets for various use cases, see the examples.

Was this page helpful?