React-native-mapbox-gl: Support for Gradle Plugin version 3.3.1 (Android)

Created on 18 Feb 2019  路  16Comments  路  Source: nitaliano/react-native-mapbox-gl

When updating to the latest Gradle Plugin 3.3.1 you lose ability to resolve all dependancies with

"ERROR: Unable to resolve dependency for.... "

classpath 'com.android.tools.build:gradle:3.3.1'

Downgrading to 3.2.1 solves the issue for time being.

classpath 'com.android.tools.build:gradle:3.2.1'

Most helpful comment

I've upgraded to the latest Gradle plugin and got some dependency errors which can be resolved.

Removed okhttp override in the app grade file so it ends up like this:

implementation project(':mapbox-react-native-mapbox-gl')

Chang the mapbox-react-native-mapbox-gl gradle file with below:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    // React Native
    compileOnly "com.facebook.react:react-native:+"

    // Mapbox SDK
    implementation 'com.mapbox.mapboxsdk:mapbox-android-services:2.2.9'

    // Fix issues
    implementation 'com.android.support:support-vector-drawable:28.0.0'
    implementation 'com.android.support:support-annotations:28.0.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.squareup.okhttp3:okhttp:3.12.1'

    implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.1@aar'

    // Mapbox plugins
    implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization:0.1.0'
    implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.3.0'
}

It works perfectly 馃憤

All 16 comments

When is this getting fixed

It is not possible to downgrade to 3.2.1 on the latest React Native (0.59) so this workaround will no longer work.

I think we should go with RN 0.59 for v7.0.0.
What do you think @nitaliano ?

Does anyone have a good suggestion for a workaround? Would really like to upgrade to RN 0.59

I've upgraded to the latest Gradle plugin and got some dependency errors which can be resolved.

Removed okhttp override in the app grade file so it ends up like this:

implementation project(':mapbox-react-native-mapbox-gl')

Chang the mapbox-react-native-mapbox-gl gradle file with below:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    // React Native
    compileOnly "com.facebook.react:react-native:+"

    // Mapbox SDK
    implementation 'com.mapbox.mapboxsdk:mapbox-android-services:2.2.9'

    // Fix issues
    implementation 'com.android.support:support-vector-drawable:28.0.0'
    implementation 'com.android.support:support-annotations:28.0.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.squareup.okhttp3:okhttp:3.12.1'

    implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.1@aar'

    // Mapbox plugins
    implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization:0.1.0'
    implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.3.0'
}

It works perfectly 馃憤

@iamswain25 Did it not work for you?

I've upgraded to the latest Gradle plugin and got some dependency errors which can be resolved.

Removed okhttp override in the app grade file so it ends up like this:

implementation project(':mapbox-react-native-mapbox-gl')

Chang the mapbox-react-native-mapbox-gl gradle file with below:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    // React Native
    compileOnly "com.facebook.react:react-native:+"

    // Mapbox SDK
    implementation 'com.mapbox.mapboxsdk:mapbox-android-services:2.2.9'

    // Fix issues
    implementation 'com.android.support:support-vector-drawable:28.0.0'
    implementation 'com.android.support:support-annotations:28.0.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.squareup.okhttp3:okhttp:3.12.1'

    implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.1@aar'

    // Mapbox plugins
    implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization:0.1.0'
    implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.3.0'
}

It works perfectly 馃憤

THIS WORKED FOR ME AFTER UPGRADING TO 0.59 OMG THANK YOU SO MUCH 馃槶

Iirc, the Okhttp override is required for certain dependecy combinations. I鈥檒l have a look at this on a larger repo and if they work there as well, get these changes into master. Thanks for finding a solution.

@RichardLindhout I spent too much time on this issue that I didn't read your instruction carefully the other day, so changed something else than the node_module mapbox-react-native-mapbox-gl gradle file. Now I have my mind back and tried again, it works perfectly fine! Thousand thanks!!

@RichardLindhout your solution also worked for me, would be a good PR

I got a PR open with #1543 that updates the example to 59 and adds support in the native lib. Can one of you guys give it a try? If it works I'll merge it to master.

This and RN59 support is now in master.

How should I install this with npm?

How should I install this with npm?

Whta do you mean? Check the installation part in the home of this repo, you have instructions for Yarn and Npm

How should I install this with npm?

with
yarn add https://github.com/nitaliano/react-native-mapbox-gl
or
npm install https://github.com/nitaliano/react-native-mapbox-gl
you get the latest version directly from github

none of the above solution worked. RN0.59

Was this page helpful?
0 / 5 - 0 ratings

Related issues

olofd picture olofd  路  3Comments

igor9silva picture igor9silva  路  3Comments

glennverschooren picture glennverschooren  路  4Comments

Craytor picture Craytor  路  3Comments

Amalp picture Amalp  路  3Comments