I have a react-native project in which I installed react-native-firebase and followed the instructions in the documentation, but when i tried to run the app i got a mismatch version in gradle so i updated gradle to 4.6, now the build is successful, but the app keeps quitting
here is my build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext {
        buildToolsVersion = "28.0.2"
        minSdkVersion = 18
        compileSdkVersion = 27
        targetSdkVersion = 26
        supportLibVersion = "27.1.1"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        classpath 'com.google.gms:google-services:4.0.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}
task wrapper(type: Wrapper) {
    gradleVersion = '4.6'
    distributionUrl = distributionUrl.replace("bin", "all")
}
and my app/build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
 * and bundleReleaseJsAndAssets).
 * These basically call `react-native bundle` with the correct arguments during the Android build
 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
 * bundle directly from the development server. Below you can see all the possible configurations
 * and their defaults. If you decide to add a configuration block, make sure to add it before the
 * `apply from: "../../node_modules/react-native/react.gradle"` line.
 *
 * project.ext.react = [
 *   // the name of the generated asset file containing your JS bundle
 *   bundleAssetName: "index.android.bundle",
 *
 *   // the entry file for bundle generation
 *   entryFile: "index.android.js",
 *
 *   // whether to bundle JS and assets in debug mode
 *   bundleInDebug: false,
 *
 *   // whether to bundle JS and assets in release mode
 *   bundleInRelease: true,
 *
 *   // whether to bundle JS and assets in another build variant (if configured).
 *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
 *   // The configuration property can be in the following formats
 *   //         'bundleIn${productFlavor}${buildType}'
 *   //         'bundleIn${buildType}'
 *   // bundleInFreeDebug: true,
 *   // bundleInPaidRelease: true,
 *   // bundleInBeta: true,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // the root of your project, i.e. where "package.json" lives
 *   root: "../../",
 *
 *   // where to put the JS bundle asset in debug mode
 *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
 *
 *   // where to put the JS bundle asset in release mode
 *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in debug mode
 *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in release mode
 *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
 *
 *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
 *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
 *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
 *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
 *   // for example, you might want to remove it from here.
 *   inputExcludes: ["android/**", "ios/**"],
 *
 *   // override which node gets called and with what additional arguments
 *   nodeExecutableAndArgs: ["node"],
 *
 *   // supply additional arguments to the packager
 *   extraPackagerArgs: []
 * ]
 */
project.ext.react = [
    entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false
/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false
android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
    defaultConfig {
        applicationId "com.dental_page_android"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}
dependencies {
    implementation project(':react-native-firebase')
    implementation "com.google.android.gms:play-services-base:16.0.1"
    implementation "com.google.firebase:firebase-core:16.0.6"
    compile project(':react-native-google-places')
    compile project(':react-native-text-gradient')
    compile project(':react-native-splash-screen')
    compile project(':react-native-linear-gradient')
    compile 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
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}
apply plugin: 'com.google.gms.google-services'
here is the documentation i followed
https://rnfirebase.io/docs/v5.x.x/installation/android
the only step I've made was updating gradle from 4.4 to 4.6 because of the android.tools.build:gradle:3.2.0 required it.
Help Appreciated
Pls, post a react-native version here.
bcoz I face similar issues and get out from here after trying some solution.
@abdul-elah-js
I have same issue, and I solved it.
I guess your problem is ' java.lang.RuntimeException: Unable to load script from assets 'index.android.bundle'.
I see the error message in the android studio Logcat tab when I installed my release app into android studio simulator.
you can try bundle your js manual from this step, before build release android app.
or, you can try use com.android.tools.build:gradle:3.0.1 in your build.gradle, because I face this issue after I upgrade to com.android.tools.build:gradle:3.2.0, and I fix it by downgrade to 3.0.1, but some feature of android 8 will be disabled, so you can choose the first workaround
Have you added the Google Service JSON file as indicated on docs?
@bbbb12179 Good solution but actually it turned out that i had a problem with react-native-google-places's play version, fixed it by excluding the version, and now it's working perfectly.
I'm also facing this issue. It's working perfectly on build version but crashes immediately on release. @abdul-elah-js could you please help me identify the package and fix conflict.
Here's my build.gradle
`
apply plugin: "com.android.application"
apply plugin: 'com.bugsnag.android.gradle'
apply plugin: 'newrelic'
import com.android.build.OutputFile
project.ext.react = [
    entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
    applicationId "com.packagename"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 2
    versionName "0.2 beta"
    multiDexEnabled true
    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
        }
    }
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86"
    }
}
buildTypes {
    release {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        signingConfig signingConfigs.release
    }
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a":1, "x86":2]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
        }
    }
}
}
dependencies {
implementation project(':react-native-firebase')
// Firebase dependencies
implementation "com.google.android.gms:play-services-base:16.0.1"
implementation "com.google.firebase:firebase-core:16.0.6"
implementation project(':react-native-device-info')
implementation project(':react-native-splash-screen')
implementation project(':react-native-camera')
implementation "com.newrelic.agent.android:android-agent:5.+"
implementation 'com.bugsnag:bugsnag-android:4.+'
compile project(':bugsnag-react-native')
compile project(':react-native-device-info')
compile project(':react-native-splash-screen')
compile project(':react-native-camera')
implementation (project(':react-native-camera')) {
    exclude group: "com.android.support"
}
implementation "com.android.support:exifinterface:+"
implementation "com.android.support:support-annotations:+"
implementation "com.android.support:support-v4:+"
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:+'
implementation 'com.google.android.gms:play-services-maps:+'
implementation project(':react-native-google-signin')
implementation project(':react-native-twitter-signin')
implementation(project(":react-native-google-signin")){
    exclude group: "com.google.android.gms" // very important
}
implementation 'com.google.android.gms:play-services-auth:15.0.0' // should be at least 15.0.0 to work with the most recent APIs
implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
implementation project(':react-native-fbsdk')
implementation 'com.android.support:multidex:1.0.3'
implementation project(':react-native-config')
implementation project(':react-native-vector-icons')
implementation project(':react-native-linear-gradient')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+"  // From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}
apply plugin: 'com.google.gms.google-services' // <--- this should be the last line
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true` 
same issue here
@sugaith for me the problem was that react-native-firebase and react-native-maps required two different googleplayservices or something like that, but overall it was a mismatch, so check your other libraries and try to figure it out
@sugaith for me the problem was that
react-native-firebaseandreact-native-mapsrequired two different googleplayservices or something like that, but overall it was a mismatch, so check your other libraries and try to figure it out
Hey. How did you solved this issue?
These days updating the library versions and putting your versions in the ext {} block then using them in your app/ gradle is the way to go. This used to be a serious problem but now is I think solved in all the libraries with the dependency style in ext {} blocks. If a library doesn't do that (yet) complain to them - as far as I know it is the only way to keep your versions consistent
@bbbb12179 You are right! Looks like downgrading com.android.tools.build:gradle to 3.0.1 in android/build.gradle got the app to running which is nice. Previously my version for that was 3.3.2 But why is this happening is still a mystery. Do you guys have updates why this is happening and how you solved it?
EDIT: Looks like also that version 3.1.0 works also 馃帀 
Android bundling's issues with where the bundle went, vs where gradle expected resources to go as it packaged are fixed after upgrading to modern react-native - they fixed it sometime during the 0.58.x series if I recall correctly, and 0.59.x works fine with modern gradle+AndroidStudio combinations, up to 3.4.x
Most helpful comment
@abdul-elah-js
I have same issue, and I solved it.
I guess your problem is ' java.lang.RuntimeException: Unable to load script from assets 'index.android.bundle'.
I see the error message in the android studio Logcat tab when I installed my release app into android studio simulator.
you can try bundle your js manual from this step, before build release android app.
or, you can try use com.android.tools.build:gradle:3.0.1 in your build.gradle, because I face this issue after I upgrade to com.android.tools.build:gradle:3.2.0, and I fix it by downgrade to 3.0.1, but some feature of android 8 will be disabled, so you can choose the first workaround