1 thought on “Crash when start (Android)

  1. Had the same problem, here is how I fixed it. Basically you have a Google Play Services version mismatch. react-native-maps for example is set fix on 9.8.0. From ./node_modules/react-native-maps/android/build.gradle:

    dependencies {
      compile "com.facebook.react:react-native:+"
      compile "com.google.android.gms:play-services-base:9.8.0"
      compile "com.google.android.gms:play-services-maps:9.8.0"
    }
    

    Meanwhile, react-native-device-info has:

    dependencies {
        compile 'com.facebook.react:react-native:+'
        compile 'com.google.android.gms:play-services-gcm:+'
    }
    

    Here is my ./android/app/build.gradle:

    dependencies {
        compile(project(':react-native-device-info')){
            exclude group: 'com.google.android.gms', module: 'play-services-gcm'
        }
        compile 'com.google.android.gms:play-services-gcm:9.8.0'
        compile project(':react-native-maps')
        compile fileTree(dir: "libs", include: ["*.jar"])
        compile "com.android.support:appcompat-v7:23.0.1"
        compile "com.facebook.react:react-native:+"  // From node_modules
    }
    

    Also, I made sure which Google Play Services version is actually installed on my Emulator by going to Settings >> App >> Google Play Services (it was 9.8.79 for me).

    So basically, look at all your dependencies, if they have Google Play Services requirements. Determine the lowest common denominator, and which version is on your emulator. Exclude Google Play Services from the compilation of your dependencies that are on an unspecified or otherwise problematic version. Specify by hand which version you really want for the Google Play Service in question.

    DO NOT mess with the files in your node_modules folder as they will be lost each time you clone your codebase / share it with someone else / install new dependencies. And then you’ll struggle for a while before remembering what is wrong.

Comments are closed.

2 thoughts on “Crash when start (Android)

  1. Had the same problem, here is how I fixed it. Basically you have a Google Play Services version mismatch. react-native-maps for example is set fix on 9.8.0. From ./node_modules/react-native-maps/android/build.gradle:

    dependencies {
      compile "com.facebook.react:react-native:+"
      compile "com.google.android.gms:play-services-base:9.8.0"
      compile "com.google.android.gms:play-services-maps:9.8.0"
    }
    

    Meanwhile, react-native-device-info has:

    dependencies {
        compile 'com.facebook.react:react-native:+'
        compile 'com.google.android.gms:play-services-gcm:+'
    }
    

    Here is my ./android/app/build.gradle:

    dependencies {
        compile(project(':react-native-device-info')){
            exclude group: 'com.google.android.gms', module: 'play-services-gcm'
        }
        compile 'com.google.android.gms:play-services-gcm:9.8.0'
        compile project(':react-native-maps')
        compile fileTree(dir: "libs", include: ["*.jar"])
        compile "com.android.support:appcompat-v7:23.0.1"
        compile "com.facebook.react:react-native:+"  // From node_modules
    }
    

    Also, I made sure which Google Play Services version is actually installed on my Emulator by going to Settings >> App >> Google Play Services (it was 9.8.79 for me).

    So basically, look at all your dependencies, if they have Google Play Services requirements. Determine the lowest common denominator, and which version is on your emulator. Exclude Google Play Services from the compilation of your dependencies that are on an unspecified or otherwise problematic version. Specify by hand which version you really want for the Google Play Service in question.

    DO NOT mess with the files in your node_modules folder as they will be lost each time you clone your codebase / share it with someone else / install new dependencies. And then you’ll struggle for a while before remembering what is wrong.

Comments are closed.