android: Firebase push notifications - FATAL UNHANDLED EXCEPTION Make sure to call FirebaseApp.initializeApp(Context) first

Android application type

Classic Xamarin.Android (MonoAndroid12.0, etc.)

Affected platform version

JetBrains Rider 2022.3.3

Description

When trying to implement a cross-platform push notification application on Xamarin, after following many youtube guides and docs on how to implement it with FCM, the android application crashes on [ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.notify.notify. Make sure to call FirebaseApp.initializeApp(Context) first.

I tried almost every suggestion on how to solve this issue that I found on the web but it seems like nothing hasn’t worked for me, I am not sure if those solutions are deprecated or not.

Thank you very much for your help.

Steps to Reproduce

  1. Install NuGet package 3.3.10 (their last stable release is 3.4.35 - but it didn’t work either)
  2. followed exactly step by step this guide https://www.youtube.com/watch?v=1Ixc_B86mDk&ab_channel=XamarinUIDesigns Also, Gerald’s guides didn’t help either : https://www.youtube.com/watch?v=7w2q2D6mR7g&ab_channel=GeraldVersluis https://www.youtube.com/watch?v=VI1wgekz5ZM&ab_channel=GeraldVersluis 3.Tried various of android api’s - now on API 33 on Pixel 5

App crashes every time.

Did you find any workaround?

Unfortunately no

Relevant log output

03-25 00:06:38.401 D/BoundBrokerSvc( 5397): onUnbind: Intent { act=com.google.android.gms.potokens.service.START dat=chimera-action:com.google.android.gms.potokens.service.START cmp=com.google.android.gms/.chimera.GmsApiService }
03-25 00:06:38.408 D/BoundBrokerSvc( 5397): onBind: Intent { act=com.google.android.gms.potokens.service.START dat=chimera-action:com.google.android.gms.potokens.service.START cmp=com.google.android.gms/.chimera.GmsApiService }
03-25 00:06:38.408 D/BoundBrokerSvc( 5397): Loading bound service for intent: Intent { act=com.google.android.gms.potokens.service.START dat=chimera-action:com.google.android.gms.potokens.service.START cmp=com.google.android.gms/.chimera.GmsApiService }
03-25 00:06:38.408 E/JavaBinder( 8537): !!! FAILED BINDER TRANSACTION !!!  (parcel size = 1028)
03-25 00:06:38.408 W/GmsClient( 8537): IGmsServiceBroker.getService failed
03-25 00:06:38.408 W/GmsClient( 8537): android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died, but this could also be caused by running out of binder buffe
03-25 00:06:38.408 W/GmsClient( 8537): 	at android.os.BinderProxy.transactNative(Native Method)
03-25 00:06:38.408 W/GmsClient( 8537): 	at android.os.BinderProxy.transact(BinderProxy.java:584)
03-25 00:06:38.408 W/GmsClient( 8537): 	at lvm.A(PG:15)
03-25 00:06:38.408 W/GmsClient( 8537): 	at kuh.run(PG:44)
03-25 00:06:38.408 W/GmsClient( 8537): 	at android.os.Handler.handleCallback(Handler.java:942)
03-25 00:06:38.408 W/GmsClient( 8537): 	at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 00:06:38.408 W/GmsClient( 8537): 	at android.os.Looper.loopOnce(Looper.java:201)
03-25 00:06:38.408 W/GmsClient( 8537): 	at android.os.Looper.loop(Looper.java:288)
03-25 00:06:38.408 W/GmsClient( 8537): 	at android.os.HandlerThread.run(HandlerThread.java:67)
03-25 00:06:38.409 E/JavaBinder( 8537): !!! FAILED BINDER TRANSACTION !!!  (parcel size = 400)
03-25 00:06:38.409 W/GmsClient( 8537): IGmsServiceBroker.getService failed
03-25 00:06:38.409 W/GmsClient( 8537): android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died, but this could also be caused by running out of binder buffe
03-25 00:06:39.120 W/GmsClient( 8406): android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died, but this could also be caused by running out of binder buffer
03-25 00:06:40.087 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Arch.Core.Common.dll
03-25 00:06:40.219 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Arch.Core.Runtime.dll
03-25 00:06:40.220 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Arch.Lifecycle.Common.dll
03-25 00:06:40.220 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Arch.Lifecycle.LiveData.Core.dll
03-25 00:06:40.220 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Arch.Lifecycle.LiveData.dll
03-25 00:06:40.220 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Arch.Lifecycle.Runtime.dll
03-25 00:06:40.220 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Arch.Lifecycle.ViewModel.dll
03-25 00:06:40.220 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.Annotations.dll
03-25 00:06:40.220 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.AsyncLayoutInflater.dll
03-25 00:06:40.220 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.Collections.dll
03-25 00:06:40.220 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.Compat.dll
03-25 00:06:40.220 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.CoordinaterLayout.dll
03-25 00:06:40.220 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.Core.UI.dll
03-25 00:06:40.220 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.Core.Utils.dll
03-25 00:06:40.220 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.CursorAdapter.dll
03-25 00:06:40.220 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.CustomView.dll
03-25 00:06:40.220 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.DocumentFile.dll
03-25 00:06:40.220 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.DrawerLayout.dll
03-25 00:06:40.220 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.Fragment.dll
03-25 00:06:40.220 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.Interpolator.dll
03-25 00:06:40.221 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.Loader.dll
03-25 00:06:40.221 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.LocalBroadcastManager.dll
03-25 00:06:40.221 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.Media.Compat.dll
03-25 00:06:40.221 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.Print.dll
03-25 00:06:40.221 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.SlidingPaneLayout.dll
03-25 00:06:40.221 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.SwipeRefreshLayout.dll
03-25 00:06:40.221 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.v4.dll
03-25 00:06:40.221 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.v7.CardView.dll
03-25 00:06:40.221 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.VersionedParcelable.dll
03-25 00:06:40.221 W/monodroid-assembly( 9259): open_from_bundles: failed to load assembly Xamarin.Android.Support.ViewPager.dll
03-25 00:06:40.230 W/monodroid-gc( 9259): GREF GC Threshold: 46080
03-25 00:06:41.337 W/m.notify.notify( 9259): Attempt to remove non-JNI local reference, dumping thread
03-25 00:06:41.926 W/FirebaseApp( 9259): Default FirebaseApp failed to initialize because no default options were found. This usually means that com.google.gms:google-services was not applied to your gradle project.
03-25 00:06:41.926 I/FirebaseInitProvider( 9259): FirebaseApp initialization unsuccessful

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 26 (13 by maintainers)

Most upvoted comments

@LinMoskovitch

At this point I think the only thing to try is to repo with your json file. Did you want to send it to me? (rather than put it in your public repo). Or create a private repo and add it there then give me access.

I will do that and send you.

@LinMoskovitch

I got that error when I tried to use your google-services.json, there was a warning in the list which said it could not filed the “client_id” or something. So I think the .json file you are using is not the right one or has the wrong format. So I created one for myself on my own google firebase account.

I didn’t make any other changes to your app, just replaced the json file and changed the package id in the AndroidManifest.xml to match my settings package id.

i would go to your firebase console https://console.firebase.google.com/ and try downloading one again.

Thanks, I think I managed to success.

Firebase based apps usually have a google-services.json file (or something similar) which controls the API keys etc. I’m not seeing that in the branch. Was it excluded on purpose?

I would expect to see an item in the csproj like

<ItemGroup>
    <GoogleServicesJson Include="google-services.json" />
</ItemGroup>

It was on purpose to prevent data leaking, can you please try again now? you should see the json now as well as in the .csjproj