Search code examples
google-mapsreact-nativereact-native-maps

react-native-map crashing the application


I tried to use react native app and having the following snippet in gradle file

dependencies {
    implementation project(':react-native-maps')
    implementation project(':react-native-geolocation-service')
    implementation project(':react-native-background-timer')
    implementation project(':react-native-mauron85-background-geolocation')
    implementation project(':react-native-contacts')
    implementation project(':react-native-gesture-handler')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
}

I have googled and found below lines solving the issues

compile(project(':react-native-maps')) {
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }
    compile 'com.google.android.gms:play-services-base:11.+'
    compile 'com.google.android.gms:play-services-maps:11.+'
    compile 'com.google.android.gms:play-services-location:+'

But i dont have compile(project.... in my gradle file

I am using

 "react": "16.6.3",
 "react-native": "0.58.6",
 "react-native-geolocation-service": "^2.0.0",
 "react-native-gesture-handler": "^1.1.0",
 "react-native-maps": "^0.23.0",

How to resolve this issue


Solution

  • compile was deprecated in favour of implementation. You can easily just replace all instances of the word compile with the word implemenation. So your dependencies would become something like this:

    dependencies {
        implementation(project(':react-native-maps')) {
          exclude group: 'com.google.android.gms', module: 'play-services-base'
          exclude group: 'com.google.android.gms', module: 'play-services-maps'
        }
        implementation 'com.google.android.gms:play-services-base:11.+'
        implementation 'com.google.android.gms:play-services-maps:11.+'
        implementation 'com.google.android.gms:play-services-location:+'
    
    
        // implementation project(':react-native-maps') // <- you can remove this as you are using it above
        implementation project(':react-native-geolocation-service')
        implementation project(':react-native-background-timer')
        implementation project(':react-native-mauron85-background-geolocation')
        implementation project(':react-native-contacts')
        implementation project(':react-native-gesture-handler')
        implementation fileTree(dir: "libs", include: ["*.jar"])
        implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
        implementation "com.facebook.react:react-native:+"  // From node_modules
    }