Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug Push Notifications: "Default FirebaseApp is not initialized" exception

Discussion in 'Player Engagement' started by coSphinkx, May 8, 2023.

  1. coSphinkx

    coSphinkx

    Joined:
    Sep 11, 2019
    Posts:
    1
    Hi! I'm using Unity 2021.3.17f1. New Android application was created, only unity-jar-resolver-1.2.176 and Push Notifications 3.0.1-pre.1 were installed. I took code from Push Notification Example.
    Token received well, but every remote notification produce an exception:

    Code (csharp):
    1.  
    2. FATAL EXCEPTION: Firebase-Messaging-Intent-Handle
    3. Process: infra.babooshka.games, PID: 10132
    4. java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process infra.babooshka.games. Make sure to call FirebaseApp.initializeApp(Context) first.
    5.     at com.google.firebase.FirebaseApp.getInstance(FirebaseApp.java:183)
    6.     at com.google.firebase.messaging.MessagingAnalytics.logToScion(com.google.firebase:firebase-messaging@@22.0.0:28)
    7.     at com.google.firebase.messaging.MessagingAnalytics.logNotificationReceived(com.google.firebase:firebase-messaging@@22.0.0:2)
    8.     at com.google.firebase.messaging.FirebaseMessagingService.passMessageIntentToSdk(com.google.firebase:firebase-messaging@@22.0.0:7)
    9.     at com.google.firebase.messaging.FirebaseMessagingService.handleMessageIntent(com.google.firebase:firebase-messaging@@22.0.0:3)
    10.     at com.google.firebase.messaging.FirebaseMessagingService.handleIntent(com.google.firebase:firebase-messaging@@22.0.0:3)
    11.     at com.google.firebase.messaging.EnhancedIntentService.lambda$processIntent$0$EnhancedIntentService(com.google.firebase:firebase-messaging@@22.0.0:1)
    12.     at com.google.firebase.messaging.EnhancedIntentService$$Lambda$0.run(Unknown Source:6)
    13.     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    14.     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    15.     at com.google.android.gms.common.util.concurrent.zza.run(com.google.android.gms:play-services-basement@@17.2.1:6)
    16.     at java.lang.Thread.run(Thread.java:920)
    17.  
     
  2. VladS_Unity

    VladS_Unity

    Unity Technologies

    Joined:
    Nov 18, 2022
    Posts:
    6
    Hello.

    Thanks for getting in touch!

    Are you using the provided `PushNotificationExample.cs` sample script while testing out your app with Push Notifications? And, just to clarify, are you using the test tool in the Push Notifications settings page to send your remote notifications?

    Also, what Android version is your test device using?

    If you could provide us with a sample project that can replicate this issue, that would be appreciated.

    For now, I recommend trying these options:
    • Did the unity-jar-resolver pick up the dependencies required by the Push SDK? You can check by using the "Display Libraries" option, found under Assets > External Dependency Manager > Android Resolver > Display Libraries (check below image). The following line should be present within, under the "dependencies" block:

      implementation 'com.google.firebase:firebase-messaging-ktx:22.0.0' // Assets/Push Notifications/Editor/Android/PushSDKDependencies.xml:8


      If it hasn't, please verify if the "PushSDKDependencies.xml" file was generated under the "Assets/Push Notifications/Editor/Android" folder, then use the Dependency Manager's "Resolve" or "Force Resolve" options to make the resolver pick it up again.
      upload_2023-5-12_12-36-7.png

    • If you do not require it for any other plugins, I recommend trying to uninstall the unity-jar-resolver. While the Push Notifications SDK does integrate with it, it does not require the External Dependency Manager to resolve it's own dependencies. In this scenario, enabling the "Custom Main Gradle Template" option under the Android Publishing settings might also help.
      upload_2023-5-12_12-47-28.png


      Hope that helps!
     
  3. Jonathan-FourFats

    Jonathan-FourFats

    Joined:
    Apr 21, 2016
    Posts:
    22
    I have the same error.

    installing the FirebaseMessaging.unitypackage from Google fixed it for me https://firebase.google.com/download/unity

    so i have both the unity's com.unity.services.push-notifications and FirebaseMessaging.unitypackage installed.

    Unity changed something to avoid Firebase duplicate dll errors.

    installing FirebaseMessaging.unitypackage broke iOS received a notification callback to fix that, remove Firebase folder in /plugins/iOS/
     
    Last edited: May 17, 2023