- mapbox: v10 latest mapbox implementation - recommended, not opensource requires access for download
- maplibre: DEFAULT open source fork of older open source mapbox libraries with many improvements, will be removed in next version
- mapbox-gl: classic mapbox libraries - should work but will be dropped, recent versions are not open source and requires access for download, will be removed in next version
Add RNMapboxMapsImpl = "mapbox"
to your gradle file - see bellow for details.
Warning: If you set a custom version, make sure you revisit, any time you update @rnmapbox/maps. Setting it to earlier version than what we exepect will likely result in a build error.
Overwrite mapbox dependencies within your android/build.gradle > buildscript > ext
section
buildscript {
ext {
// ...
RNMapboxMapsImpl = "mapbox" // required for v10
}
}
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 credentials
and Configure your secret token
.
Then under section allprojects/repositories
add your data:
// android/build.gradle
allprojects {
repositories {
// ...other repos
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'] ?: ""
}
}
// ...even more repos?
}
}
Warning: If you set a custom version, make sure you revisit, any time you update @rnmapbox/maps. Setting it to earlier version than what we exepect will likely result in a build error.
Set RNMapboxMapsLibs
in android/build.gradle > buildscript > ext
section
buildscript {
ext {
// ...
RNMapboxMapsImpl = "mapbox"
RNMapboxMapsLibs = { // optional - only required if you want to customize it
implementation 'com.mapbox.maps:android:10.6.0'
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:5.4.1'
}
}
}
If you see 2 files found with path 'lib/arm64-v8a/libc++_shared.so' from inputs
issue see possible workaround.
MapLibre is an OSS fork of MapboxGL. This is the default, and should work without any changes in gradle files.
Overwrite mapbox dependencies within your android/build.gradle > buildscript > ext
section
buildscript {
ext {
// ...
RNMapboxMapsImpl = "maplibre" // optional - as this is the default
RNMapboxMapsLibs = { // optional - only required if you want to customize it
implementation ("org.maplibre.gl:android-sdk:9.5.2")
implementation ("org.maplibre.gl:android-sdk-turf:5.9.0")
implementation ("org.maplibre.gl:android-plugin-localization-v9:1.0.0")
implementation ("org.maplibre.gl:android-plugin-annotation-v9:1.0.0")
implementation ("org.maplibre.gl:android-plugin-markerview-v9:1.0.0")
}
}
}
Feel free to check out the /example
projects android/build.gradle
for inspiration!
We've set up default Mapbox dependencies for you.
Feel free to check em out here
However, it is also possible to set a custom version of the Mapbox SDK
Which will overwrite our defaults.
Add something like the following to your android/build.gradle > buildscript > ext
section:
// android/build.gradle
buildscript {
// ... stuff
ext {
RNMapboxMapsImpl = "mapbox-gl"
// ... stuff
RNMapboxMapsLibs = {
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.7.1'
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:5.8.0'
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:5.8.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-gestures:0.7.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.8.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v9:0.14.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v9:0.4.0'
}
// ... more stuff?
}
}
NOTICE, 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 credentials
and Configure your secret token
.
Then under section allprojects/repositories
add your data:
// android/build.gradle
allprojects {
repositories {
// ...other repos
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'] ?: ""
}
}
// ...even more repos?
}
}
Feel free to check out the /example
projects android/build.gradle
for inspiration!
code android/app/build.gradle
add the following
android {
packagingOptions {
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}
}