Closed arminsal1 closed 7 years ago
Can we see your JS code usage please?
@Ehesp Sure thing! I initialized in a separate Firebase.js file and then imported that into my app's Home.js file.
Firebase.js:
import RNFirebase from 'react-native-firebase'
const firebase = RNFirebase.initializeApp({
// config options
debug: true,
persistence: true,
APIKey: "{API-KEY}",
databaseURL: "{My-DatabaseURL-String}",
storageBucket: "{My-StorageBucket-String}"
});
export default firebase;
Then I just imported like so: import firebase from "./components/Firebase";
The error is especially puzzling because the JS setup runs with no issues on iOS.
@Ehesp Any updates? Tried debugging more on the android side with no success.
The Firebase SDK should be initialised automatically on Android. I'd suggest checking your application's startup logs to make sure there aren't any errors - it could be that there's something invalid in your google-services.json, or something else going wrong at startup.
@chrisbianca I appreciate you taking the time to help me out! I have an iOS programming background so Android debugging is a struggle for me. I tried downloading the latest google-services.json from firebase and replaced the old one, but the error persists. This is my Android Studio output:
08-30 11:04:27.244 6633-6633/com.viva I/art: Not late-enabling -Xcheck:jni (already on)
08-30 11:04:27.244 6633-6633/com.viva W/art: Unexpected CPU variant for X86 using defaults: x86
08-30 11:04:27.277 6633-6633/com.viva V/fb-UnpackingSoSource: locked dso store /data/user/0/com.viva/lib-main
08-30 11:04:27.278 6633-6633/com.viva V/fb-UnpackingSoSource: deps mismatch on deps store: regenerating
08-30 11:04:27.278 6633-6633/com.viva V/fb-UnpackingSoSource: so store dirty: regenerating
08-30 11:04:27.313 6633-6633/com.viva D/ApkSoSource: not allowing consideration of lib/x86/libRSSupport.so: deferring to libdir
[ 08-30 11:04:27.313 1560: 1581 D/ ]
HostConnection::get() New Host Connection established 0x878aec40, tid 1581
08-30 11:04:27.313 6633-6633/com.viva D/ApkSoSource: not allowing consideration of lib/x86/libblasV8.so: deferring to libdir
08-30 11:04:27.313 6633-6633/com.viva D/ApkSoSource: not allowing consideration of lib/x86/libfb.so: deferring to libdir
08-30 11:04:27.313 6633-6633/com.viva D/ApkSoSource: not allowing consideration of lib/x86/libfolly_json.so: deferring to libdir
08-30 11:04:27.313 6633-6633/com.viva D/ApkSoSource: not allowing consideration of lib/x86/libgifimage.so: deferring to libdir
08-30 11:04:27.314 6633-6633/com.viva D/ApkSoSource: not allowing consideration of lib/x86/libglog.so: deferring to libdir
08-30 11:04:27.314 6633-6633/com.viva D/ApkSoSource: not allowing consideration of lib/x86/libglog_init.so: deferring to libdir
08-30 11:04:27.314 6633-6633/com.viva D/ApkSoSource: not allowing consideration of lib/x86/libgnustl_shared.so: deferring to libdir
08-30 11:04:27.314 6633-6633/com.viva D/ApkSoSource: not allowing consideration of lib/x86/libicu_common.so: deferring to libdir
08-30 11:04:27.314 6633-6633/com.viva D/ApkSoSource: not allowing consideration of lib/x86/libimagepipeline.so: deferring to libdir
08-30 11:04:27.315 6633-6633/com.viva D/ApkSoSource: not allowing consideration of lib/x86/libjsc.so: deferring to libdir
08-30 11:04:27.315 6633-6633/com.viva D/ApkSoSource: not allowing consideration of lib/x86/libreactnativejni.so: deferring to libdir
08-30 11:04:27.315 6633-6633/com.viva D/ApkSoSource: not allowing consideration of lib/x86/librsjni.so: deferring to libdir
08-30 11:04:27.315 6633-6633/com.viva D/ApkSoSource: not allowing consideration of lib/x86/libstatic-webp.so: deferring to libdir
08-30 11:04:27.316 6633-6633/com.viva D/ApkSoSource: not allowing consideration of lib/x86/libwebp.so: deferring to libdir
08-30 11:04:27.316 6633-6633/com.viva D/ApkSoSource: not allowing consideration of lib/x86/libwebpimage.so: deferring to libdir
08-30 11:04:27.316 6633-6633/com.viva D/ApkSoSource: not allowing consideration of lib/x86/libyoga.so: deferring to libdir
08-30 11:04:27.316 6633-6633/com.viva V/fb-UnpackingSoSource: regenerating DSO store com.facebook.soloader.ApkSoSource
08-30 11:04:27.317 6633-6633/com.viva V/fb-UnpackingSoSource: starting syncer worker
08-30 11:04:27.332 6633-6633/com.viva V/fb-UnpackingSoSource: releasing dso store lock for /data/user/0/com.viva/lib-main (from syncer thread)
08-30 11:04:27.333 6633-6633/com.viva V/fb-UnpackingSoSource: not releasing dso store lock for /data/user/0/com.viva/lib-main (syncer thread started)
08-30 11:04:27.338 6633-6633/com.viva W/com.facebook.internal.Validate: FacebookActivity is not declared in the AndroidManifest.xml, please add com.facebook.FacebookActivity to your AndroidManifest.xml file. See https://developers.facebook.com/docs/android/getting-started for more info.
08-30 11:04:27.407 6633-6633/com.viva W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
08-30 11:04:27.416 6633-6659/com.viva D/NetworkSecurityConfig: No Network Security Config specified, using platform default
08-30 11:04:27.493 6633-6633/com.viva D/ReactNative: ReactInstanceManager.ctor()
08-30 11:04:27.513 6633-6633/com.viva D/ReactNative: ReactInstanceManager.createReactContextInBackground()
08-30 11:04:27.513 6633-6633/com.viva D/ReactNative: ReactInstanceManager.recreateReactContextInBackgroundInner()
08-30 11:04:27.533 6633-6633/com.viva W/unknown:ReactNative: Packager connection already open, nooping.
08-30 11:04:27.533 6633-6633/com.viva W/unknown:ReactNative: Inspector connection already open, nooping.
08-30 11:04:27.613 6633-6681/com.viva I/OpenGLRenderer: Initialized EGL, version 1.4
08-30 11:04:27.613 6633-6681/com.viva D/OpenGLRenderer: Swap behavior 1
08-30 11:04:27.644 6633-6681/com.viva E/EGL_emulation: tid 6681: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
08-30 11:04:27.644 6633-6681/com.viva W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x9f583340, error=EGL_BAD_MATCH
08-30 11:04:27.801 6633-6681/com.viva E/EGL_emulation: tid 6681: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
08-30 11:04:27.801 6633-6681/com.viva W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x8f524260, error=EGL_BAD_MATCH
08-30 11:04:27.998 6633-6633/com.viva D/ReactNative: ReactInstanceManager.onJSBundleLoadedFromServer()
08-30 11:04:28.004 6633-6633/com.viva I/art: Thread[1,tid=6633,Native,Thread*=0xa7e8b400,peer=0x74bae610,"main"] recursive attempt to load library "/data/app/com.viva-1/lib/x86/libfb.so"
08-30 11:04:28.006 6633-6633/com.viva D/ReactNative: ReactInstanceManager.recreateReactContextInBackground()
08-30 11:04:28.006 6633-6633/com.viva D/ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
08-30 11:04:28.007 6633-6696/com.viva D/ReactNative: ReactInstanceManager.createReactContext()
08-30 11:04:28.018 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTGroupViewManager
08-30 11:04:28.019 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTGroupShadowNode
08-30 11:04:28.022 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTShapeViewManager
08-30 11:04:28.022 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTShapeShadowNode
08-30 11:04:28.022 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTTextViewManager
08-30 11:04:28.022 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTTextShadowNode
08-30 11:04:28.023 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.picker.ReactDialogPickerManager
08-30 11:04:28.024 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.uimanager.LayoutShadowNode
08-30 11:04:28.027 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.drawer.ReactDrawerLayoutManager
08-30 11:04:28.029 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.picker.ReactDropdownPickerManager
08-30 11:04:28.030 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.scroll.ReactHorizontalScrollViewManager
08-30 11:04:28.032 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.progressbar.ReactProgressBarViewManager
08-30 11:04:28.033 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.progressbar.ProgressBarShadowNode
08-30 11:04:28.035 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.scroll.ReactScrollViewManager
08-30 11:04:28.037 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.slider.ReactSliderManager
08-30 11:04:28.039 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.slider.ReactSliderManager$ReactSliderShadowNode
08-30 11:04:28.039 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.switchview.ReactSwitchManager
08-30 11:04:28.040 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.switchview.ReactSwitchManager$ReactSwitchShadowNode
08-30 11:04:28.040 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.toolbar.ReactToolbarManager
08-30 11:04:28.041 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.webview.ReactWebViewManager
08-30 11:04:28.042 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.swiperefresh.SwipeRefreshLayoutManager
08-30 11:04:28.044 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTSurfaceViewManager
08-30 11:04:28.045 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.art.ARTSurfaceViewShadowNode
08-30 11:04:28.045 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.frescosupport.FrescoBasedReactTextInlineImageViewManager
08-30 11:04:28.046 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.frescosupport.FrescoBasedReactTextInlineImageShadowNode
08-30 11:04:28.051 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.image.ReactImageManager
08-30 11:04:28.052 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.modal.ReactModalHostManager
08-30 11:04:28.053 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.modal.ModalHostShadowNode
08-30 11:04:28.054 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactRawTextManager
08-30 11:04:28.056 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactTextShadowNode
08-30 11:04:28.056 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.textinput.ReactTextInputManager
08-30 11:04:28.058 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.textinput.ReactTextInputShadowNode
08-30 11:04:28.058 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactTextViewManager
08-30 11:04:28.058 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.view.ReactViewManager
08-30 11:04:28.060 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.viewpager.ReactViewPagerManager
08-30 11:04:28.060 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.react.views.text.ReactVirtualTextViewManager
08-30 11:04:28.060 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.reactnative.photoview.PhotoViewManager
08-30 11:04:28.064 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class dk.madslee.imageSequence.RCTImageSequenceManager
08-30 11:04:28.066 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.lwansbrough.RCTCamera.RCTCameraViewManager
08-30 11:04:28.067 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.cmcewen.blurview.BlurViewManager
08-30 11:04:28.068 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.reactnative.androidsdk.FBLikeViewManager
08-30 11:04:28.069 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.reactnative.androidsdk.FBLoginButtonManager
08-30 11:04:28.072 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.reactnative.androidsdk.FBSendButtonManager
08-30 11:04:28.073 6633-6696/com.viva W/art: Before Android 4.1, method boolean com.facebook.share.widget.ShareButtonBase.canShare() would have incorrectly overridden the package-private method in android.widget.TextView
08-30 11:04:28.073 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.facebook.reactnative.androidsdk.FBShareButtonManager
08-30 11:04:28.074 6633-6696/com.viva W/unknown:ViewManagerPropertyUpdater: Could not find generated setter for class com.BV.LinearGradient.LinearGradientManager
08-30 11:04:28.087 6633-6696/com.viva D/RNFirebaseAnalytics: New instance
08-30 11:04:28.089 6633-6696/com.viva E/unknown:ReactNative: Exception in native call
java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.viva. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source)
at io.invertase.firebase.auth.RNFirebaseAuth.<init>(RNFirebaseAuth.java:56)
at io.invertase.firebase.auth.RNFirebaseAuthPackage.createNativeModules(RNFirebaseAuthPackage.java:26)
at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:106)
at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1071)
at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1042)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:980)
at com.facebook.react.ReactInstanceManager.access$600(ReactInstanceManager.java:109)
at com.facebook.react.ReactInstanceManager$4.run(ReactInstanceManager.java:802)
at java.lang.Thread.run(Thread.java:761)
08-30 11:04:28.145 6633-6681/com.viva E/EGL_emulation: tid 6681: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
08-30 11:04:28.145 6633-6681/com.viva W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x8f5244a0, error=EGL_BAD_MATCH
Are you able to see any problem points?
I've just compared this to my app starting up, and I have the following as an entry in the log:
08-30 16:18:39.152 13289 13289 I FirebaseInitProvider: FirebaseApp initialization successful
I don't do anything specifically to do this, it's done automatically on start up, so I'm not quite sure why yours isn't doing the same.
The only thing I wonder is whether the configuration is incorrect - e.g. the package name doesn't match, or the SHA is set incorrectly
@chrisbianca Do you mean checking to see if my package name and SHA match what's in my Google Developer account?
@arminsal1 Yes, exactly. Validate that the package name in your AndroidManifest.xml is what is specified in the Firebase console project setup, and also that the SHA matches as well.
@chrisbianca I went into my dashboard settings and the package name matches, but I don't have any SHA. Is that necessary for Firebase? The library worked for me without it before, but that was during v1.x so I'm not sure if that makes a difference.
Update: I found my Debug SHA1 in Android Studio and added it to my Firebase settings, but the problem persists. This error is killing me
@arminsal1 I'm really not sure what to suggest. You look to have done everything that's required to get it up and running. All I could perhaps suggest is starting a clean project, adding RNFirebase to that and getting it working, then porting over anything that's different to your existing project?
@chrisbianca Alright, it looks like that's my only choice at this point. Thank you, I appreciate your help
Upgrading my project to RN 0.48 seemed to clean up whatever issue I was having and now it's running smoothly on Android with RNFirebase V3 😎
I guess it was down to some file not being initilized somewhere - joys of RN!
The issue is up in RN 0.52.2 I'll try to figure out what's happening out there
01-30 17:51:29.450 11639 15249 E unknown:ReactNative: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.qsoft.rentdemo. Make sure to call FirebaseApp.initializeApp(Context) first.
01-30 17:51:29.450 11639 15249 E unknown:ReactNative: at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
01-30 17:51:29.450 11639 15249 E unknown:ReactNative: at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
01-30 17:51:29.450 11639 15249 E unknown:ReactNative: at io.invertase.firebase.messaging.RNFirebaseMessaging.getToken(RNFirebaseMessaging.java:71)
01-30 17:59:10.198 12300 12300 E FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
01-30 17:59:10.200 1347 2609 W ActivityManager: Unable to start service Intent { act=com.google.firebase.MESSAGING_EVENT pkg=org.telegram.messenger (has extras) } U=0: not found
01-30 17:59:10.200 12300 12300 E FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.
01-30 18:00:35.053 12300 12300 E FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
01-30 18:00:35.054 1347 2694 W ActivityManager: Unable to start service Intent { act=com.google.firebase.MESSAGING_EVENT pkg=org.telegram.messenger (has extras) } U=0: not found
01-30 18:00:35.055 12300 12300 E FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.
01-30 18:00:35.075 12300 12300 E FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
01-30 18:00:35.076 1347 2123 W ActivityManager: Unable to start service Intent { act=com.google.firebase.MESSAGING_EVENT pkg=org.telegram.messenger (has extras) } U=0: not found
01-30 18:00:35.077 12300 12300 E FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.
01-30 18:02:27.140 16080 16080 D FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
01-30 18:02:27.154 16080 16080 D FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
01-30 18:02:27.178 16080 16080 I FA : adb shell setprop debug.firebase.analytics.app ru.yandex.metro
01-30 18:02:27.187 16080 16080 I FirebaseInitProvider: FirebaseApp initialization successful
The first log message tells us that FirebaseApp is not initialized. And the last log is initializing of Firebaseapp.
Firebaseapp is initialized too late: 10 seconds after it was attempted to use
Okay. I don't know what was the problem.
Solved by:
Then installed the latest version as described here: https://rnfirebase.io/docs/v3.2.x/installation/initial-setup
Then I had to update all my play-services dependencies in android/app/build.gradle to 11.6.0 version, because firebase is using 11.6.0 at the moment I'm writing this post.
Here is how my android/app/build.gradle dependencies block looks like:
dependencies {
compile(project(':react-native-firebase')) {
transitive = false
}
// Firebase dependencies
compile "com.google.firebase:firebase-core:11.6.0"
compile "com.google.firebase:firebase-messaging:11.6.0"
compile project(':react-native-background-timer')
compile(project(':react-native-maps')) {
exclude group: 'com.google.android.gms'
}
compile (project(':react-native-device-info')) {
exclude group: "com.google.android.gms"
}
compile (project(':react-native-camera')) {
exclude group: "com.google.android.gms"
}
compile project(':react-native-image-picker')
compile project(':react-native-oauth')
compile project(':react-native-svg')
compile project(':react-native-vector-icons')
compile project(':react-native-device-info')
compile project(path: ':react-native-interactable')
compile project(':react-native-photo-view')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile ("com.google.android.gms:play-services-base:11.6.0") {
force = true;
}
compile ("com.google.android.gms:play-services-maps:11.6.0") {
force = true;
}
compile ("com.google.android.gms:play-services-gcm:11.6.0") {
force = true;
}
compile project(':react-native-facebook-login')
compile project(':react-native-check-app-install')
compile project(':react-native-fetch-blob')
compile project(':non-conflicting-webview')
}
Hope this will help somebody....
Reason and solution:
This is the common error you will get most of the time.
Reason: when you integrate your project with the Firebase it adds the dependencies
implementation 'com.google.firebase:firebase-auth:16.1.0' implementation 'com.google.android.gms:play-services-auth:16.0.1'
and classpath
classpath 'com.google.gms:google-services:4.1.0'
you just need to update them This is how you can update https://youtu.be/5d1g9aqczIE
I'm experiencing this issue on version 6 but only when I enable remote debugging... Any help?
"@react-native-firebase/app": "^6.3.4",
"react-native": "0.61.5",
I find it very odd that the documentation of version 5 seems to be more robust than version 6. I'm completely newbie in firebase and I'm having trouble learning this as there are almost no resources for version 6, I can see some resources for version 5 and the docs of v5 is a lot better.
I have the same error but I am not using firebase at all in my app... do you know why that may be
I'm experiencing this issue on version 6 but only when I enable remote debugging... Any help?
"@react-native-firebase/app": "^6.3.4", "react-native": "0.61.5",
I find it very odd that the documentation of version 5 seems to be more robust than version 6. I'm completely newbie in firebase and I'm having trouble learning this as there are almost no resources for version 6, I can see some resources for version 5 and the docs of v5 is a lot better.
i think you missing add classpath 'com.google.gms:google-services:4.3.2' and apply plugin: 'com.google.gms.google-services'
For anyone still paying attention, here is a from-scratch demonstrator script, built from the v6+ docs (which are I think pretty robust actually?) - https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-v6.sh
For anyone still paying attention, here is a from-scratch demonstrator script, built from the v6+ docs (which are I think pretty robust actually?) - https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-v6.sh
Is react-native-firebase doing the same things on react-native link
? so that means, after linking (which they said in latest react-native is no longer required to be ran manually) everything should work well, including when you enable debug mode, correct? What I'm missing is, I followed what the documentation said but cannot enable debug mode, it worked well if I don't enable debug mode, but then I can't debug efficiently, then I learned about the firebase react-native template and I tried it out, to my surprise, it works as I expected, I will try to create a replicate repo and post it here.
For all who have problems to enable Debugging Mode of RN while after adding firebase messaging to their project.
The appears if you have firebase in your project (with auto-linking) but firebase is not (yet) configured properly:
As soon as you enter Debugging Mode the JS is executed in Chrome instead of the Android JS engine (Hermes/JSC). Now it seems like if you use chrome then getConstants
is called when you start the app. This will trigger the exception if firebase is not configured before getConstants
is called. In Hermes it seems like getConstants
is not called directly when the app starts but only when you access firebase via a JS import.
You can fix this by configuring firebase through the The Google Services Gradle Plugin: https://developers.google.com/android/guides/google-services-plugin Alternatively you can also skip this plugin and do all manually as we do: https://github.com/Integreat/integreat-app/blob/88fb78693185749799297db4ed90a8f1b4bf5232/native/android/app/buildConfigs.gradle#L50
Very interesting - I'm aware that running under the RN debugger can affect JS execution but had not thought of this impact. @maxammann if there is some place in the docs where you could briefly warn people that running under the RN debugger will cause app initialization to fail under X, Y, Z circumstances that might be helpful for future people
@mikehardy sadly I don't have time to spend more time on this issue. I just hope that people will find this issue.
Therefore here some keywords to find this issue: Debugging Mode Firebase React Native getContext initializeApp
this is android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { ext { buildToolsVersion = "33.0.0" minSdkVersion = 21 compileSdkVersion = 33 targetSdkVersion = 33
// We use NDK 23 which hasm both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath 'com.google.gms:google-services:4.3.15'
}
}
this is android/app/build.gradle
apply plugin: "com.android.application" apply plugin: "com.facebook.react" apply plugin: 'com.google.gms.google-services' // <- Add this line
/**
By default you don't need to apply any configuration, just uncomment the lines you need. / react { / Folders */ // The root of your project, i.e. where "package.json" lives. Default is '..' // root = file("../") // The folder where the react-native NPM package is. Default is ../node_modules/react-native // reactNativeDir = file("../node_modules/react-native") // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen // codegenDir = file("../node_modules/@react-native/codegen") // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js // cliFile = file("../node_modules/react-native/cli.js")
/ Variants / // The list of variants to that are debuggable. For those we're going to // skip the bundling of the JS bundle and the assets. By default is just 'debug'. // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. // debuggableVariants = ["liteDebug", "prodDebug"]
/ Bundling / // A list containing the node command and its flags. Default is just 'node'. // nodeExecutableAndArgs = ["node"] // // The command to run when bundling. By default is 'bundle' // bundleCommand = "ram-bundle" // // The path to the CLI configuration file. Default is empty. // bundleConfig = file(../rn-cli.config.js) // // The name of the generated asset file containing your JS bundle // bundleAssetName = "MyApplication.android.bundle" // // The entry file for bundle generation. Default is 'index.android.js' or 'index.js' // entryFile = file("../js/MyApplication.android.js") // // A list of extra flags to pass to the 'bundle' commands. // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle // extraPackagerArgs = []
/ Hermes Commands / // The hermes compiler command to run. By default it is 'hermesc' // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc" // // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map" // hermesFlags = ["-O", "-output-source-map"] }
/**
/**
def jscFlavor = 'org.webkit:android-jsc-intl:+'
Date.toLocaleString
and String.localeCompare
thatandroid { ndkVersion rootProject.ext.ndkVersion
compileSdkVersion rootProject.ext.compileSdkVersion
namespace "com.digianafresh"
defaultConfig {
applicationId "com.digianafresh"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 37
versionName "3.1.7"
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
}
dependencies { // The version of react-native is set by the React Native Gradle Plugin implementation("com.facebook.react:react-android") debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { exclude group:'com.squareup.okhttp3', module:'okhttp' }
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}
implementation project(':payu-non-seam-less-react')
// implementation project(':react-native-firebase')
// implementation platform('com.google.firebase:firebase-bom:28.2.1')
// implementation 'com.google.firebase:firebase-installations:17.2.0'
implementation platform('com.google.firebase:firebase-bom:32.6.0')
implementation('com.google.firebase:firebase-analytics')
// implementation("com.google.firebase:firebase-app")
// implementation("com.google.firebase:firebase-messaging")
}
// buildscript { // dependencies { // // ... other dependencies // // NOTE: if you are on react-native 0.71 or below, you must not update // // the google-services plugin past version 4.3.15 // classpath 'com.google.gms:google-services:4.4.0' // // Add me --- /\ // } // }
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
this is an AndroidManifest.xml file
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.digianafresh" xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" tools:ignore="CoarseFineLocation" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove" />
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:theme="@style/AppTheme" tools:node="replace">
<!-- <meta-data android:name="com.facebook.sdk.ClientToken"
android:value="@string/facebook_client_token"/> -->
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/SplashTheme"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.payu.ui.view.activities.CheckoutActivity"
android:exported="false" />
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCxiRDyR13T32dU_VdNRyoiO9_4xhmt5dA" />
<meta-data android:name="com.google.android.gms.version" android:value="12451000" />
<meta-data
android:name="google_analytics_adid_collection_enabled"
android:value="false" />
<!-- <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />-->
<!-- firebase -->
<service android:name="com.google.firebase.components.ComponentDiscoveryService"
android:directBootAware="true" android:exported="false">
<meta-data
android:name="com.google.firebase.components:com.google.firebase.installations.FirebaseInstallationsRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:com.google.firebase.firestore.FirestoreRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:com.google.firebase.iid.Registrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:com.google.firebase.auth.FirebaseAuthRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:com.google.firebase.database.DatabaseRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data
android:name="com.google.firebase.components:com.google.firebase.messaging.FirebaseMessagingRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
</service>
<service
android:name="com.google.firebase.messaging.FirebaseMessagingService"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<receiver
android:name="com.google.firebase.messaging.FirebaseMessagingReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
<!-- firebase -->
here I'm getting error
Default Firebase App is not initialized in this process com.digianafresh. Make sure to call Firebase App.InitializeApp(Context) first. 26 27 28 requestUserPermission()
@ashish-hexalitics this is a closed issue, please do not post on closed issues, especially if they are from years ago, that's bad form as it pings all the participants of a dead issue with your likely unrelated information.
Open a new issue if you need to please
okay i will take care of it
On Wed, Dec 6, 2023 at 10:39 PM Mike Hardy @.***> wrote:
@ashish-hexalitics https://github.com/ashish-hexalitics this is a closed issue, please do not post on closed issues, especially if they are from years ago, that's bad form as it pings all the participants of a dead issue with your likely unrelated information.
Open a new issue if you need to please
— Reply to this email directly, view it on GitHub https://github.com/invertase/react-native-firebase/issues/360#issuecomment-1843310678, or unsubscribe https://github.com/notifications/unsubscribe-auth/BBZEN4UVUBDR5DXI2WPG6HDYICRCXAVCNFSM4DYNV7A2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBUGMZTCMBWG44A . You are receiving this because you were mentioned.Message ID: @.***>
This error happens immediately whenever I run the android version of my project. iOS has no issues. I know V3 is coming and should do away with this altogether, but I'd like to resolve this as soon as possible.
build.gradle:
app/build.gradle:
MainActivity.java:
MainApplication.java:
AndroidManifest.xml:
I also have the google-services.json from Firebase in the /android/app/ folder
Environment