Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: Introduce gradle variables to customize mapbox lib versions #1088

Merged

Conversation

mfazekas
Copy link
Contributor

See: https://docs.mapbox.com/android/maps/overview/#configure-credentials for credential configuration.

Add following to buildscipt/ext

        rnmbglMapboxLibs = "com.mapbox.mapboxsdk:mapbox-sdk-services:5.1.0;com.mapbox.mapboxsdk:mapbox-android-sdk:9.5.0;com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.8.0"
        rnmbglMapboxPlugins = "com.mapbox.mapboxsdk:mapbox-android-gestures:0.6.0;com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v9:0.12.0;com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v9:0.4.0;com.mapbox.mapboxsdk:mapbox-sdk-turf:5.1.0"

Add following to 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'] ?: ""
            }
        }

To your top level build gradle.

Complete example:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "29.0.2"
        minSdkVersion = 16
        compileSdkVersion = 29
        targetSdkVersion = 29

        rnmbglMapboxLibs = "com.mapbox.mapboxsdk:mapbox-sdk-services:5.1.0;com.mapbox.mapboxsdk:mapbox-android-sdk:9.5.0;com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.8.0"
        rnmbglMapboxPlugins = "com.mapbox.mapboxsdk:mapbox-android-gestures:0.6.0;com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v9:0.12.0;com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v9:0.4.0;com.mapbox.mapboxsdk:mapbox-sdk-turf:5.1.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.5.3")

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        jcenter()
        maven { url 'https://jitpack.io' }

        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'] ?: ""
            }
        }
    }
}

@mfazekas mfazekas merged commit 02ddcef into rnmapbox:master Oct 20, 2020
@ferdicus
Copy link
Member

nice, thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants