nitaliano / react-native-mapbox-gl

A Mapbox GL react native module for creating custom maps
Other
2.16k stars 697 forks source link

Support for Gradle Plugin version 3.3.1 (Android) #1511

Closed mtannerfors closed 5 years ago

mtannerfors commented 5 years ago

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'

DanielUche commented 5 years ago

When is this getting fixed

matt-oakes commented 5 years ago

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

pinpong commented 5 years ago

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

makirby commented 5 years ago

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

RichardLindhout commented 5 years ago

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 👍

RichardLindhout commented 5 years ago

@iamswain25 Did it not work for you?

smol-honk commented 5 years ago

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 😭

kristfal commented 5 years ago

Iirc, the Okhttp override is required for certain dependecy combinations. I’ll 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.

iamswain25 commented 5 years ago

@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!!

huanvu commented 5 years ago

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

kristfal commented 5 years ago

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.

kristfal commented 5 years ago

This and RN59 support is now in master.

herhumoolah commented 5 years ago

How should I install this with npm?

sfratini commented 5 years ago

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

WeslleyNasRocha commented 5 years ago

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

mahdieh-dev commented 5 years ago

none of the above solution worked. RN0.59