0
votes

I'm running an android react native app and a successfull build is completed, but when the app is launched it crashes, I can't even open it. I've tried multiple solutions I find on the internet, but none seem to work. Here are my gradle files:

gradle.app

apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
        nodeExecutableAndArgs : ["/usr/local/bin/node"]
];

apply from: "../../node_modules/react-native/react.gradle"

def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.1'
    defaultConfig {
        applicationId "com.tradeup"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 3
        versionName "1.7"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
}

dependencies {
    compile project(':react-native-fcm')
    compile project(':react-native-code-push')
    compile project(':react-native-image-picker')
    compile project(':react-native-splash-screen')
    compile (project(':react-native-fcm')){
        exclude group: "com.google.firebase"
    }
    compile project(':react-native-svg')
    compile project(':react-native-vector-icons')
    compile project(':react-native-linear-gradient')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  

    compile "com.google.firebase:firebase-core:11.2.0"

    compile "com.google.android.gms:play-services-base:11.2.0"

    compile "com.google.firebase:firebase-analytics:11.2.0"
    compile "com.google.firebase:firebase-auth:11.2.0"
    compile "com.google.firebase:firebase-config:11.2.0"
    compile "com.google.firebase:firebase-crash:11.2.0"
    compile "com.google.firebase:firebase-database:11.2.0"
    compile "com.google.firebase:firebase-messaging:11.2.0"
    compile "com.google.firebase:firebase-perf:11.2.0"
    compile "com.google.firebase:firebase-storage:11.2.0"
}

apply plugin: 'com.google.gms.google-services'

I've been trying to fix this for a while now, and the ios version runs fine. Thanks.

2
tried with 11.2.2 ?Amit K. Saha

2 Answers

0
votes

This is due to different libraries are trying to use different gms service's version. Try with this in your build.gradle file -

configurations.all {
   resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.getRequested().getGroup() == 'com.google.android.gms') {
            details.useVersion('x.x.x') // here should be your version ---> details.useVersion('15.0.1') //the latest one
        }
    }
}
dependencies {
    compile project(':react-native-fcm')
    compile project(':react-native-code-push')
    compile project(':react-native-image-picker')
    compile project(':react-native-splash-screen')
    compile (project(':react-native-fcm')){
        exclude group: "com.google.firebase"
    }
    compile project(':react-native-svg')
    compile project(':react-native-vector-icons')
    compile project(':react-native-linear-gradient')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  

    compile "com.google.firebase:firebase-core:11.2.0"

    compile "com.google.android.gms:play-services-base:11.2.0"

    compile "com.google.firebase:firebase-analytics:11.2.0"
    compile "com.google.firebase:firebase-auth:11.2.0"
    compile "com.google.firebase:firebase-config:11.2.0"
    compile "com.google.firebase:firebase-crash:11.2.0"
    compile "com.google.firebase:firebase-database:11.2.0"
    compile "com.google.firebase:firebase-messaging:11.2.0"
    compile "com.google.firebase:firebase-perf:11.2.0"
    compile "com.google.firebase:firebase-storage:11.2.0"
}
0
votes

I added this to gradle and it solved my problem

implementation "com.google.android.gms:play-services-base:15.0.1"

implementation "com.google.android.gms:play-services-gcm:15.0.1"