React-native-firebase: Android - Fatal Exception: com.facebook.react.common.JavascriptException

Created on 3 May 2019  路  3Comments  路  Source: invertase/react-native-firebase

Hi,

So I just followed all the steps to install react-native-firebase and it's working perfectly on iOS, but on Android the app keeps crashing with the following error being caught by Crashlytics

Fatal Exception: com.facebook.react.common.JavascriptException: null is not an object (evaluating 'a.AnalyticsSettings.setDispatchInterval'), stack:
value@847:342 (...)

Any ideas?


Project Files

Android

android/build.gradle:

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

buildscript {
    ext {
        firebaseVersion = "17.1.0"
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0'
        classpath 'com.google.gms:google-services:4.2.0'
        // 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"
        }
    }
}

android/app/build.gradle:

(...)
dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    // Firebase
    implementation project(':react-native-firebase')
    // Firebase dependencies
    implementation "com.google.firebase:firebase-core:16.0.8"
    implementation "com.google.android.gms:play-services-base:16.1.0"

    implementation project(':@react-native-community_async-storage')
    implementation project(':react-native-webview')
    implementation project(':react-native-cookies')
    implementation project(':react-native-config')
    implementation project(':react-native-device-info')
    implementation project(':react-native-video')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-push-notification')
    implementation project(':react-native-onesignal')
    implementation project(':react-native-material-kit')

    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.google.android.gms:play-services-gcm:+"
    implementation ('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
        transitive = true;
    }
}

// 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'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

android/settings.gradle:

(...)
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
include ':@react-native-community_async-storage'
project(':@react-native-community_async-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/async-storage/android')
include ':react-native-webview'
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')
include ':react-native-cookies'
project(':react-native-cookies').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-cookies/android')
include ':react-native-config'
project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/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-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-push-notification'
project(':react-native-push-notification').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-push-notification/android')
include ':react-native-onesignal'
project(':react-native-onesignal').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-onesignal/android')
include ':react-native-material-kit'
project(':react-native-material-kit').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-material-kit/android')

include ':app'

MainApplication.java:

(...)

import android.app.Application;

import com.facebook.react.ReactApplication;
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.analytics.RNFirebaseAnalyticsPackage; 
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
import com.reactnativecommunity.webview.RNCWebViewPackage;
import com.psykar.cookiemanager.CookieManagerPackage;
import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.brentvatne.react.ReactVideoPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;
import com.geektime.rnonesignalandroid.ReactNativeOneSignalPackage;
import com.github.xinthink.rnmk.ReactMaterialKitPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.crashlytics.android.Crashlytics;
import io.fabric.sdk.android.Fabric;

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

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return false;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
            new RNFirebasePackage(),
            new RNFirebaseAnalyticsPackage(),
            new AsyncStoragePackage(),
            new RNCWebViewPackage(),
            new CookieManagerPackage(),
            new ReactNativeConfigPackage(),
            new RNDeviceInfo(),
            new ReactVideoPackage(),
            new VectorIconsPackage(),
            new ReactNativePushNotificationPackage(),
            new ReactNativeOneSignalPackage(),
            new ReactMaterialKitPackage()
      );
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    Fabric.with(this, new Crashlytics());
    SoLoader.init(this, /* native exopackage */ false);
  }
}


Environment

  • 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

  • If known, the version of the platform are you experiencing the issue on:

    • Android API 27

  • Operating System:

    • [x] MacOS, version: N/A

    • [ ] Windows, version: N/A

    • [ ] Other, please specify: N/A

  • Build Tools:

    • Android Studio 3.4,

  • React Native version:

    • 0.59.5

  • React Native Firebase library version:

    • 5.3.1

  • Firebase module(s) you're using that has the issue:

    • [x] N/A

    • [ ] Authentication

    • [ ] Analytics

    • [ ] Cloud Firestore

    • [ ] Cloud Messaging (FCM)

    • [ ] Crashlytics

    • [ ] Dynamic Links

    • [ ] Functions Callable

    • [ ] In App Messaging

    • [ ] Indexing

    • [ ] Invites

    • [ ] Instance ID

    • [ ] ML Kit

    • [ ] Notifications

    • [ ] Performance Monitoring

    • [ ] Realtime Database

    • [ ] Remote Config

    • [ ] Storage

  • Are you using TypeScript?

    • [x] No

    • [ ] Yes, version: N/A

  • Are you using Expo, e.g. ExpoKit?

    • [x] No

    • [ ] Yes, I've _not_ ejected

    • [ ] Yes, but I have ejected to ExpoKit

    • [ ] Yes, but I have ejected to vanilla React Native

    • Expo version: N/A

Most helpful comment

@marcoj I'm still facing this issue. Can you please elaborate a bit, how you resolve it

Here is the error:
com.facebook.react.common.JavascriptException: TypeError: f[n] is not a function. (In 'fn', 'f[n]' is undefined), stack:
@345:173
value@45:1280
value@25:3685
@25:841
value@25:2939
value@25:813
value@-1
at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java
at java.lang.reflect.Method.invoke (Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:371)
at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:150)
at com.facebook.react.bridge.queue.NativeRunnable.run (Native Method)
at android.os.Handler.handleCallback (Handler.java:883)
at android.os.Handler.dispatchMessage (Handler.java:100)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:26)
at android.os.Looper.loop (Looper.java:237)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:225)
at java.lang.Thread.run (Thread.java:919)

All 3 comments

fixed, nothing to do with react-native-firebase. The reason was cached index.android.bundle

@marcoj can you please elaborate a bit, how you resolve it

@marcoj I'm still facing this issue. Can you please elaborate a bit, how you resolve it

Here is the error:
com.facebook.react.common.JavascriptException: TypeError: f[n] is not a function. (In 'fn', 'f[n]' is undefined), stack:
@345:173
value@45:1280
value@25:3685
@25:841
value@25:2939
value@25:813
value@-1
at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java
at java.lang.reflect.Method.invoke (Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:371)
at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:150)
at com.facebook.react.bridge.queue.NativeRunnable.run (Native Method)
at android.os.Handler.handleCallback (Handler.java:883)
at android.os.Handler.dispatchMessage (Handler.java:100)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:26)
at android.os.Looper.loop (Looper.java:237)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:225)
at java.lang.Thread.run (Thread.java:919)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tranty9597 picture tranty9597  路  79Comments

TalEliel picture TalEliel  路  48Comments

bitfabrikken picture bitfabrikken  路  52Comments

kevinEsherick picture kevinEsherick  路  57Comments

adirzoari picture adirzoari  路  50Comments