If you are using autolinking feature introduced in React-Native 0.60.0
you do not need any additional steps.
Notice, that if you're using the default Mapbox Android SDK (which is packed in with this lib)
and are on newer Android OS version (API 30+),
you'll encounter Fatal Exception: java.lang.SecurityException: getDataNetworkTypeForSubscriber
.
Either update the Mapbox Android SDK as described below in the Mapbox Maps SDK
section,
OR add the following line to your android/app/build.gradle
to pull in the missing dependency.
dependencies {
// ...
implementation 'com.mapbox.mapboxsdk:mapbox-android-telemetry:6.1.0'
// ...
}
It is possible to set a custom version of the Mapbox SDK
Add the following to your android/build.gradle
:
under section allprojects/repositories
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
// Do not change the username below.
// This should always be `mapbox` (not your username).
username = 'mapbox'
// Use the secret token you stored in gradle.properties as the password
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
}
}
Overwrite mapbox dependencies within your android/app/build.gradle
:
dependencies {
// ...
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.1'
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:5.6.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.9.0'
// ...
Check the current version of the SDK here.
If you are using newer versions of the SDK, you will need to authorize your download of the Maps SDK via a secret access token with the DOWNLOADS:READ
scope.
This guide explains how to configure the secret token under section Configure your secret token
.
MapLibre is an OSS fork of MapboxGL
Overwrite mapbox dependecies within your android/build.gradle
buildscript {
ext {
// ...
rnmbglMapboxLibs = {
implementation ("org.maplibre.gl:android-sdk:9.2.1")
implementation ("com.mapbox.mapboxsdk:mapbox-sdk-turf:5.3.0")
}
rnmbglMapboxPlugins = {
implementation ("com.mapbox.mapboxsdk:mapbox-android-gestures:0.7.0")
implementation ("com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v9:0.12.0") {
exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-sdk'
}
implementation ("com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.8.0") {
exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-sdk'
}
implementation ("com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v9:0.4.0") {
exclude group: 'com.mapbox.mapboxsdk', module: 'mapbox-android-sdk'
}
}
}
}
repositories {
// ...
maven {
url = "https://dl.bintray.com/maplibre/maplibre-gl-native"
}
}