React-native-firebase: (:fire:) The [[DEFAULT]] firebase app has not been initialized

Created on 7 Jun 2019  路  11Comments  路  Source: invertase/react-native-firebase

Issue

I realize that there are a lot of other issues with the same title but none of the provided solutions there have helped me.

After updating react-native from 0.57.7 to 0.59.4 react-native-firebase won't work on android anymore. On iOS everything works fine, but android crashes with the titled error message.

I tried a lot of the steps recommended in the other issues, but none of it helped. It still crashes with The [[DEFAULT]] firebase app has not been initialized. As said before updating everything worked just fine. Any help here is much appreciated.


Project Files

This is my android/build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'

        classpath 'com.google.gms:google-services:4.1.0'

        classpath 'com.google.firebase:perf-plugin:1.2.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 21
        compileSdkVersion = 28
        targetSdkVersion = 26
        supportLibVersion = "28.0.0"
    }
}

project(':react-native-fbsdk') {
  configurations.all {
    resolutionStrategy {
      force 'com.facebook.android:facebook-android-sdk:4.22.1'
    }
  }
}

ext {
    compileSdkVersion = 28
    buildToolsVersion = "28.0.3"
}

subprojects { subproject ->
    afterEvaluate{
        if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

allprojects {
    configurations.all {
        resolutionStrategy {
            force 'com.facebook.android:facebook-android-sdk:4.22.1'
            force 'com.google.android.gms:play-services-basement:16.2.0'
            force 'com.google.android.gms:play-services-tasks:16.0.1'
            force 'com.google.android.gms:play-services-iid:16.0.1'
            force 'com.google.android.gms:play-services-measurement-base:16.0.5'
            force 'com.google.firebase:firebase-analytics:16.0.6'
            force 'com.google.android.gms:play-services-analytics:16.0.6'
            force 'com.google.firebase:firebase-iid:17.0.4'
        }
    }
    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"
        }
        maven {
          url 'https://riskident.jfrog.io/riskident/android-release'
          credentials {
            username '*********'
            password '*********'
          }
        }
        maven {
            url "$rootDir/libs/aybottomnavigation"
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        maven {
            url "https://raw.githubusercontent.com/wingify/vwo-mobile-android/hybrid/"
        }

        maven { url "$rootDir/../node_modules/react-native/android" }
        maven { url "https://maven.localytics.com/public" }
    }

}

This is my android/app/build.gradle:

apply plugin: "com.android.application"
// Added because react-native-config doesn't run properly for android
// Watch here => https://github.com/luggit/react-native-config/issues/34
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

apply plugin: 'com.google.firebase.firebase-perf'

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
apply from: "../../node_modules/react-native-sentry/sentry.gradle"

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

def releaseKeystorePropertiesFile = rootProject.file("release.keystore.properties")
def releaseKeystoreProperties = new Properties()
releaseKeystoreProperties.load(new FileInputStream(releaseKeystorePropertiesFile))

def debugKeystorePropertiesFile = rootProject.file("debug.keystore.properties")
def debugKeystoreProperties = new Properties()
debugKeystoreProperties.load(new FileInputStream(debugKeystorePropertiesFile))

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }
    defaultConfig {
        applicationId "**************"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        multiDexEnabled true
        versionCode Integer.parseInt(project.env.get("APP_BUILD_NUMBER"))
        versionName project.env.get("APP_VERSION")
        testBuildType System.getProperty('testBuildType', 'debug')  //this will later be used to control the test apk build type
        missingDimensionStrategy "minReactNative", "minReactNative46" //read note
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        resValue "string", "build_config_package", "************"
    }
    signingConfigs {
        debug {
            keyAlias debugKeystoreProperties['keyAlias']
            keyPassword debugKeystoreProperties['keyPassword']
            storeFile file(debugKeystoreProperties['storeFile'])
            storePassword debugKeystoreProperties['storePassword']
        }
        release {
            keyAlias releaseKeystoreProperties['keyAlias']
            keyPassword releaseKeystoreProperties['keyPassword']
            storeFile file(releaseKeystoreProperties['storeFile'])
            storePassword releaseKeystoreProperties['storePassword']
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk true  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    buildTypes {
        debug {
            manifestPlaceholders = [excludeSystemAlertWindowPermission: "false"]
            signingConfig signingConfigs.debug
        }
        release {
            manifestPlaceholders = [excludeSystemAlertWindowPermission: "true"]
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.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, "arm64-v8a": 3, "x86_64": 4]
            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-localize')
    implementation fileTree(dir: "libs", include: ["*.jar"])

    implementation project(':react-native-webview')

    implementation project(':react-native-firebase')
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation 'com.android.support:design:27.1.0'

    implementation project(':react-native-risk-ident')
    implementation project(':react-native-haptic-feedback')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation project(':ahbottomnavigation')
    implementation(project(':react-native-navigation')) {
        exclude group: 'com.aurelhubert'
    }
    implementation project(':merryjs-photo-viewer')
    implementation project(':react-native-video')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-sentry')
    implementation project(':react-native-linear-gradient')
    implementation project(':react-native-google-analytics-bridge')
    implementation project(':react-native-fbsdk')
    implementation project(':react-native-device-info')
    implementation project(':react-native-config')
    implementation project(':react-native-adjust')
    implementation project(':react-native-account-picker')
    implementation project(':localytics-react-native')
    implementation project(':react-native-action-sheet')
    implementation project(':react-native-system-setting')

    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.facebook.android:facebook-android-sdk:[4.22.1)'
    implementation 'com.google.gms:google-services:4.1.0'
    implementation 'com.google.android.gms:play-services-gcm:16.0.0'


    implementation 'com.localytics.android:library:5.5.0'

    implementation 'com.vwo:mobile:2.4.1@aar'
    implementation project(':vwo-react-native')
    implementation 'com.android.support:support-core-utils:27.1.1'

    androidTestImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test:rules:1.0.1'
    // the forked version of [email protected] ^^ does not have FB AppLinks.
    // compile 'com.facebook.android:facebook-applinks:4.28.0'
    implementation "com.android.support:support-compat:27.0.3"
    // Firebase dependencies

    implementation "com.google.firebase:firebase-core:16.0.6"
    implementation "com.google.firebase:firebase-config:16.1.3"
    implementation "com.google.firebase:firebase-messaging:17.3.4"

    implementation "com.android.support:design:27.1.0"

    implementation 'com.google.firebase:firebase-perf:17.0.0'

    implementation project(':react-native-code-push')
}

// 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'

And my manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="***********" xmlns:tools="http://schemas.android.com/tools">
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.WAKE_LOCK" />
  <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

  <application android:name=".MainApplication" android:largeHeap="true" android:hardwareAccelerated="true" android:allowBackup="true" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:theme="@style/Theme.AppCompat.Light.NoActionBar">
    <activity android:name="com.localytics.android.PushTrackingActivity" android:exported="false" tools:replace="exported"/>
    <service android:name="com.localytics.android.InstanceIDListenerService" android:exported="false">
      <intent-filter>
        <action android:name="com.google.android.gms.iid.InstanceID" />
      </intent-filter>
    </service>

    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    <!-- Optionally, register AnalyticsReceiver and AnalyticsService to support background
          dispatching on non-Google Play devices -->
    <receiver android:name="com.google.android.gms.analytics.AnalyticsReceiver" android:enabled="true">
      <intent-filter>
        <action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
      </intent-filter>
    </receiver>
    <service android:name="com.google.android.gms.analytics.AnalyticsService" android:enabled="true" android:exported="false"/>

    <!-- Optionally, register CampaignTrackingReceiver and CampaignTrackingService to enable
          installation campaign reporting -->
    <receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver" android:exported="true">
      <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
      </intent-filter>
    </receiver>
    <service android:name="com.google.android.gms.analytics.CampaignTrackingService" />
    <receiver android:name="com.localytics.android.ReferralReceiver" android:exported="true">
      <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
      </intent-filter>
    </receiver>
    <activity android:name=".MainActivity" android:screenOrientation="portrait" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:windowSoftInputMode="adjustResize" android:alwaysRetainTaskState="true" android:launchMode="singleTask" android:allowTaskReparenting="true">
      <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="***********" android:host="*************" />
      </intent-filter>

      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>

      <intent-filter>
        <data android:scheme="@string/AMP_LOCALYTICS_ANDROID_APP_KEY" />
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
      </intent-filter>

      <intent-filter>
        <!-- This is just configuration -->
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
      </intent-filter>
    </activity>
    <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
  </application>

</manifest>

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like:

# N/A
#### `AppDelegate.m`:
// N/A


Android

Click To Expand

#### `android/build.gradle`:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'

        classpath 'com.google.gms:google-services:4.1.0'

        classpath 'com.google.firebase:perf-plugin:1.2.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 21
        compileSdkVersion = 28
        targetSdkVersion = 26
        supportLibVersion = "28.0.0"
    }
}

project(':react-native-fbsdk') {
  configurations.all {
    resolutionStrategy {
      force 'com.facebook.android:facebook-android-sdk:4.22.1'
    }
  }
}

ext {
    compileSdkVersion = 28
    buildToolsVersion = "28.0.3"
}

subprojects { subproject ->
    afterEvaluate{
        if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

allprojects {
    configurations.all {
        resolutionStrategy {
            force 'com.facebook.android:facebook-android-sdk:4.22.1'
            force 'com.google.android.gms:play-services-basement:16.2.0'
            force 'com.google.android.gms:play-services-tasks:16.0.1'
            force 'com.google.android.gms:play-services-iid:16.0.1'
            force 'com.google.android.gms:play-services-measurement-base:16.0.5'
            force 'com.google.firebase:firebase-analytics:16.0.6'
            force 'com.google.android.gms:play-services-analytics:16.0.6'
            force 'com.google.firebase:firebase-iid:17.0.4'
        }
    }
    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"
        }
        maven {
          url 'https://riskident.jfrog.io/riskident/android-release'
          credentials {
            username '*********'
            password '*********'
          }
        }
        maven {
            url "$rootDir/libs/aybottomnavigation"
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        maven {
            url "https://raw.githubusercontent.com/wingify/vwo-mobile-android/hybrid/"
        }

        maven { url "$rootDir/../node_modules/react-native/android" }
        maven { url "https://maven.localytics.com/public" }
    }

}
#### `android/app/build.gradle`:
apply plugin: "com.android.application"
// Added because react-native-config doesn't run properly for android
// Watch here => https://github.com/luggit/react-native-config/issues/34
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

apply plugin: 'com.google.firebase.firebase-perf'

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
apply from: "../../node_modules/react-native-sentry/sentry.gradle"

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

def releaseKeystorePropertiesFile = rootProject.file("release.keystore.properties")
def releaseKeystoreProperties = new Properties()
releaseKeystoreProperties.load(new FileInputStream(releaseKeystorePropertiesFile))

def debugKeystorePropertiesFile = rootProject.file("debug.keystore.properties")
def debugKeystoreProperties = new Properties()
debugKeystoreProperties.load(new FileInputStream(debugKeystorePropertiesFile))

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }
    defaultConfig {
        applicationId "**************"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        multiDexEnabled true
        versionCode Integer.parseInt(project.env.get("APP_BUILD_NUMBER"))
        versionName project.env.get("APP_VERSION")
        testBuildType System.getProperty('testBuildType', 'debug')  //this will later be used to control the test apk build type
        missingDimensionStrategy "minReactNative", "minReactNative46" //read note
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        resValue "string", "build_config_package", "de.aboutyou.mobile.app"
    }
    signingConfigs {
        debug {
            keyAlias debugKeystoreProperties['keyAlias']
            keyPassword debugKeystoreProperties['keyPassword']
            storeFile file(debugKeystoreProperties['storeFile'])
            storePassword debugKeystoreProperties['storePassword']
        }
        release {
            keyAlias releaseKeystoreProperties['keyAlias']
            keyPassword releaseKeystoreProperties['keyPassword']
            storeFile file(releaseKeystoreProperties['storeFile'])
            storePassword releaseKeystoreProperties['storePassword']
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk true  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    buildTypes {
        debug {
            manifestPlaceholders = [excludeSystemAlertWindowPermission: "false"]
            signingConfig signingConfigs.debug
        }
        release {
            manifestPlaceholders = [excludeSystemAlertWindowPermission: "true"]
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.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, "arm64-v8a": 3, "x86_64": 4]
            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-localize')
    implementation fileTree(dir: "libs", include: ["*.jar"])

    implementation project(':react-native-webview')

    implementation project(':react-native-firebase')
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation 'com.android.support:design:27.1.0'

    implementation project(':react-native-risk-ident')
    implementation project(':react-native-haptic-feedback')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation project(':ahbottomnavigation')
    implementation(project(':react-native-navigation')) {
        exclude group: 'com.aurelhubert'
    }
    implementation project(':merryjs-photo-viewer')
    implementation project(':react-native-video')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-sentry')
    implementation project(':react-native-linear-gradient')
    implementation project(':react-native-google-analytics-bridge')
    implementation project(':react-native-fbsdk')
    implementation project(':react-native-device-info')
    implementation project(':react-native-config')
    implementation project(':react-native-adjust')
    implementation project(':react-native-account-picker')
    implementation project(':localytics-react-native')
    implementation project(':react-native-action-sheet')
    implementation project(':react-native-system-setting')

    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.facebook.android:facebook-android-sdk:[4.22.1)'
    implementation 'com.google.gms:google-services:4.1.0'
    implementation 'com.google.android.gms:play-services-gcm:16.0.0'


    implementation 'com.localytics.android:library:5.5.0'

    implementation 'com.vwo:mobile:2.4.1@aar'
    implementation project(':vwo-react-native')
    implementation 'com.android.support:support-core-utils:27.1.1'

    androidTestImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test:rules:1.0.1'
    // the forked version of [email protected] ^^ does not have FB AppLinks.
    // compile 'com.facebook.android:facebook-applinks:4.28.0'
    implementation "com.android.support:support-compat:27.0.3"
    // Firebase dependencies

    implementation "com.google.firebase:firebase-core:16.0.6"
    implementation "com.google.firebase:firebase-config:16.1.3"
    implementation "com.google.firebase:firebase-messaging:17.3.4"

    implementation "com.android.support:design:27.1.0"

    implementation 'com.google.firebase:firebase-perf:17.0.0'

    implementation project(':react-native-code-push')
}

// 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'
#### `android/settings.gradle`:
rootProject.name = '***************'
include ':react-native-localize'
project(':react-native-localize').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-localize/android')

include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')

include ':localytics-react-native'
project(':localytics-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/localytics-react-native/android')

include ':react-native-sentry'
project(':react-native-sentry').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sentry/android')

include ':react-native-risk-ident'
project(':react-native-risk-ident').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-risk-ident/android')

include ':react-native-open-settings'
project(':react-native-open-settings').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-open-settings/android')

include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/android/app')

include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')

include ':react-native-haptic-feedback'
project(':react-native-haptic-feedback').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-haptic-feedback/android')

include ':react-native-google-analytics-bridge'
project(':react-native-google-analytics-bridge').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-analytics-bridge/android')

include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')

include ':react-native-fbsdk'
project(':react-native-fbsdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk/android')

include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')

include ':react-native-config'
project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android')

include ':react-native-adjust'
project(':react-native-adjust').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-adjust/android')

include ':react-native-action-sheet'
project(':react-native-action-sheet').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-action-sheet/android')

include ':react-native-account-picker'
project(':react-native-account-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-account-picker/android')

include ':localytics-react-native'
project(':localytics-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/localytics-react-native/android')

include ':react-native-webview'
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')

include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')

include ':react-native-system-setting'
project(':react-native-system-setting').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-system-setting/android')

include ':react-native-risk-ident'
project(':react-native-risk-ident').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-risk-ident/android')

include ':ahbottomnavigation'
project(':ahbottomnavigation').projectDir = new File(rootProject.projectDir, 'libs/ahbottomnavigation')

include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/android/app')

include ':merryjs-photo-viewer'
project(':merryjs-photo-viewer').projectDir = new File(rootProject.projectDir, '../node_modules/@merryjs/photo-viewer/android')

include ':react-native-account-picker'
project(':react-native-account-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-account-picker/android')

include ':react-native-webkit-localstorage-reader'
project(':react-native-webkit-localstorage-reader').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webkit-localstorage-reader/android')

include ':react-native-google-analytics-bridge'
project(':react-native-google-analytics-bridge').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-analytics-bridge/android')

include ':localytics-react-native'
project(':localytics-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/localytics-react-native/android')

include ':react-native-locale-detector'
project(':react-native-locale-detector').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-locale-detector/android')

include ':react-native-haptic-feedback'
project(':react-native-haptic-feedback').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-haptic-feedback/android')

include ':react-native-video'
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android')

include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')

include ':react-native-sentry'
project(':react-native-sentry').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sentry/android')

include ':react-native-locale-detector'
project(':react-native-locale-detector').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-locale-detector/android')

include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')

include ':react-native-fbsdk'
project(':react-native-fbsdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk/android')

include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')

include ':react-native-config'
project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android')

include ':react-native-adjust'
project(':react-native-adjust').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-adjust/android')

include ':localytics-react-native'
project(':localytics-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/localytics-react-native/android')

include ':react-native-action-sheet'
project(':react-native-action-sheet').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-action-sheet/android')

include ':vwo-react-native'
project(':vwo-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/vwo-react-native/android')

include ':app'

#### `MainApplication.java`:
package com.example.app;

import android.app.Application;
import android.util.Log;
import android.os.Build;
import android.net.Uri;
import android.app.Activity;
import android.app.NotificationManager;
import android.support.v4.app.NotificationCompat;
import android.content.Intent;
import android.webkit.WebView;

import com.reactnativenavigation.NavigationApplication;
import com.reactnativenavigation.controllers.ActivityCallbacks;

import com.reactcommunity.rnlocalize.RNLocalizePackage;
import com.reactnativecommunity.webview.RNCWebViewPackage;
import com.reactnativeriskident.RNRiskidentPackage;
import com.vwo.VWOReactNativePackage;
import com.ninty.system.setting.SystemSettingPackage;
import com.localytics.react.android.LLLocalyticsPackage;
import com.BV.LinearGradient.LinearGradientPackage;
import com.mkuczera.RNReactNativeHapticFeedbackPackage;
import com.idehub.GoogleAnalyticsBridge.GoogleAnalyticsBridgePackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
import com.adjust.nativemodule.AdjustPackage;
import com.actionsheet.ActionSheetPackage;
import com.accountpicker.RNAccountPickerPackage;
import com.merryjs.PhotoViewer.MerryPhotoViewPackage;
import com.ninty.system.setting.SystemSettingPackage;
import com.brentvatne.react.ReactVideoPackage;
import com.oblador.vectoricons.VectorIconsPackage;

import java.util.Arrays;
import java.util.List;

import com.localytics.android.Localytics;
import com.localytics.android.MessagingListenerV2Adapter;
import com.localytics.android.PushCampaign;

import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;
import com.facebook.react.modules.network.ForwardingCookieHandler;
import com.facebook.react.bridge.Callback;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.soloader.SoLoader;
import com.facebook.applinks.AppLinkData;

import io.sentry.RNSentryPackage;

import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.config.RNFirebaseRemoteConfigPackage;
import io.invertase.firebase.analytics.RNFirebaseAnalyticsPackage;
import io.invertase.firebase.perf.RNFirebasePerformancePackage;

import com.microsoft.codepush.react.CodePush;

public class MainApplication extends NavigationApplication {
    @Override
    public String getJSMainModuleName() {
        return "index";
    }

    @Override
    public boolean isDebug() {
        // Make sure you are using BuildConfig from your own application
        return BuildConfig.DEBUG;
    }

    @Override
    public boolean clearHostOnActivityDestroy(Activity activity) {
        // This solves the issue where the splash screen does not go away
        // after the app is killed by the OS cause of memory or a long time in the
        // background
        return false;
    }

     @Override
    public String getJSBundleFile() { 
        return CodePush.getJSBundleFile();
    }

    private static CallbackManager mCallbackManager = CallbackManager.Factory.create();

    protected static CallbackManager getCallbackManager() {
        return mCallbackManager;
    }

    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
          new RNReactNativeHapticFeedbackPackage(),
          new CodePush("****************", MainApplication.this, BuildConfig.DEBUG),
          new MerryPhotoViewPackage(),
          new LLLocalyticsPackage(),
          new RNAccountPickerPackage(),
          new ReactVideoPackage(),
          new ReactNativeConfigPackage(),
          new FBSDKPackage(mCallbackManager),
          new RNSentryPackage(),
          new ActionSheetPackage(),
          new LinearGradientPackage(),
          new RNDeviceInfo(),
          new VectorIconsPackage(),
          new AdjustPackage(),
          new GoogleAnalyticsBridgePackage(),
          new RNRiskidentPackage(),
          new VWOReactNativePackage(),
          new SystemSettingPackage(),
          new RNFirebasePackage(),
          new RNFirebaseRemoteConfigPackage(),
          new RNFirebaseAnalyticsPackage(),
          new RNFirebasePerformancePackage(),
          new RNCWebViewPackage(),
          new RNLocalizePackage());
    }

    @Override
    public void onCreate() {
        super.onCreate();

        setActivityCallbacks(new ActivityCallbacks() {
            @Override
            public void onActivityResult(int requestCode, int resultCode, Intent data) {
                mCallbackManager.onActivityResult(requestCode, resultCode, data);
            }
        });

        SoLoader.init(this, /* native exopackage */ false);

        FacebookSdk.sdkInitialize(getApplicationContext());

        // https://developers.facebook.com/docs/reference/androidsdk/current/facebook/com/facebook/applinks/applinkdata.html
        AppLinkData.fetchDeferredAppLinkData(this, new AppLinkData.CompletionHandler() {
            @Override
            public void onDeferredAppLinkDataFetched(AppLinkData appLinkData) {
                if (appLinkData != null) {
                    Uri uri = appLinkData.getTargetUri();
                    if (uri != null && uri.isHierarchical()) {
                        Intent i = new Intent(Intent.ACTION_VIEW);
                        i.setData(uri);
                        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        startActivity(i);
                    }
                }
            }
        });

        AppEventsLogger.activateApp(this);
        Localytics.setLoggingEnabled(false);
        Localytics.autoIntegrate(this);
        Localytics.registerPush();

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
            Localytics.setMessagingListener(new MessagingListenerV2Adapter() {
                @Override
                public NotificationCompat.Builder localyticsWillShowPushNotification(NotificationCompat.Builder builder,
                                                                                     PushCampaign campaign) {
                    return builder
                            .setSmallIcon(R.drawable.ic_notification);
                }
            });
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            WebView.setWebContentsDebuggingEnabled(BuildConfig.ENABLE_WEB_DEBUGGING == "true");
        }
    }

    @Override
    public List<ReactPackage> createAdditionalReactPackages() {
        return getPackages();
    }

}

#### `AndroidManifest.xml`:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="***********" xmlns:tools="http://schemas.android.com/tools">
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.WAKE_LOCK" />
  <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

  <application android:name=".MainApplication" android:largeHeap="true" android:hardwareAccelerated="true" android:allowBackup="true" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:theme="@style/Theme.AppCompat.Light.NoActionBar">
    <activity android:name="com.localytics.android.PushTrackingActivity" android:exported="false" tools:replace="exported"/>
    <service android:name="com.localytics.android.InstanceIDListenerService" android:exported="false">
      <intent-filter>
        <action android:name="com.google.android.gms.iid.InstanceID" />
      </intent-filter>
    </service>

    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    <!-- Optionally, register AnalyticsReceiver and AnalyticsService to support background
          dispatching on non-Google Play devices -->
    <receiver android:name="com.google.android.gms.analytics.AnalyticsReceiver" android:enabled="true">
      <intent-filter>
        <action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
      </intent-filter>
    </receiver>
    <service android:name="com.google.android.gms.analytics.AnalyticsService" android:enabled="true" android:exported="false"/>

    <!-- Optionally, register CampaignTrackingReceiver and CampaignTrackingService to enable
          installation campaign reporting -->
    <receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver" android:exported="true">
      <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
      </intent-filter>
    </receiver>
    <service android:name="com.google.android.gms.analytics.CampaignTrackingService" />
    <receiver android:name="com.localytics.android.ReferralReceiver" android:exported="true">
      <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
      </intent-filter>
    </receiver>
    <activity android:name=".MainActivity" android:screenOrientation="portrait" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:windowSoftInputMode="adjustResize" android:alwaysRetainTaskState="true" android:launchMode="singleTask" android:allowTaskReparenting="true">
      <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="***********" android:host="*************" />
      </intent-filter>

      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>

      <intent-filter>
        <data android:scheme="@string/AMP_LOCALYTICS_ANDROID_APP_KEY" />
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
      </intent-filter>

      <intent-filter>
        <!-- This is just configuration -->
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
      </intent-filter>
    </activity>
    <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
  </application>

</manifest>


Environment

Click To Expand

**`react-native info` output:**

info 
  React Native Environment Info:
    System:
      OS: macOS 10.14.2
      CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
      Memory: 231.39 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 8.15.1 - ~/.nvm/versions/node/v8.15.1/bin/node
      Yarn: 1.15.2 - /usr/local/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v8.15.1/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 24, 27, 28
        Build Tools: 27.0.3, 28.0.3
        System Images: android-24 | Intel x86 Atom_64, android-24 | Google APIs Intel x86 Atom_64, android-24 | Google Play Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.4 AI-183.6156.11.34.5522156
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.6 => 16.8.6 
      react-native: 0.59.4 => 0.59.4 
    npmGlobalPackages:
      react-native-git-upgrade: 0.2.7
- **Platform that you're experiencing the issue on**: - [ ] iOS - [x] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`Firebase` module(s) you're using that has the issue:** - `e.g. Instance ID` - **Are you using `TypeScript`?** - `Y`




Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]

Android Build Error Question

Most helpful comment

Hi We have exactly the same error after upgrading from 0.57.5 to 0.59.9. It seems that the error come from classpath 'com.google.gms:google-services:4.1.0' in your build.gradle you should upgrade to 4.2.0

All 11 comments

Hi We have exactly the same error after upgrading from 0.57.5 to 0.59.9. It seems that the error come from classpath 'com.google.gms:google-services:4.1.0' in your build.gradle you should upgrade to 4.2.0

This fixed the issue for me, thx.

Yes - they have decoupled the versioning but they still have very strong inter-dependencies. Thanks @jvolonda42 for helping out and and @JohannesKlauss glad you are working now!

I have same problem, after updating react-native from 0.55.4 to 0.61.4. But upgrading 'com.google.gms:google-services' to 4.2.0 doesn't it work, too.

I'm having the same issue with RN 0.61.4 and the react-native-firebase 5.6.0, 'com.google.gms:google-services' is 4.2.0

Then it's probably a different issue @Terkhos ?
4.3.3 is the google-services plugin version at this point
And it works, either way: https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh

First, we must add google-services.json from Firebase console, in android/app.
(https://support.google.com/firebase/answer/7015592?hl=en)
then,
In order for Android to parse this file, add the google-services gradle plugin as a dependency to your project in the project level build.gradle file:
////////////////////////////////////////////////////////////
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.2.0'
}
}
///////////////////////////////////////////////////////////

To apply the plugin to your project, add the following to the VERY BOTTOM of your app android/app/build.gradle file:
////////////////////////////////////////////////////////
apply plugin: 'com.google.gms.google-services'
///////////////////////////////////////////////////////

Last step is too important, because there isn't in firebase 6 document.

You'll want version 4.3.3 at this point, and it's covered in the document https://invertase.io/oss/react-native-firebase/quick-start/android-firebase-credentials#applying-the-config-file

Here's the lines where I demonstrate the dependency and then invoking it at the bottom as you mention: https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-v6.sh#L22

Then it's probably a different issue @Terkhos ?
4.3.3 is the google-services plugin version at this point
And it works, either way: https://github.com/mikehardy/rnfbdemo/blob/master/make-demo.sh

I managed to fix this by placing the lines end of the file:
apply plugin: 'com.google.gms.google-services' com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true`

This is outdated advice. Use plugin version 4.3.3 and you can enable the (useful) version check. They fixed the issue that caused problems with it

This is outdated advice. Use plugin version 4.3.3 and you can enable the (useful) version check. They fixed the issue that caused problems with it

I removed the mentioned line and it is working now, which is weird since it wasn't working before without the line.

Was this page helpful?
0 / 5 - 0 ratings