OneSignal / OneSignal-Xamarin-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Xamarin app with OneSignal. https://onesignal.com
Other
105 stars 50 forks source link

FATAL EXCEPTION: Firebase-TokenService #170

Closed srdmnc closed 4 years ago

srdmnc commented 4 years ago

Description:

App crashes on FIRST RUN due to FATAL EXCEPTION: Firebase-TokenService. But when opening the app again (after the crash), everything works fine. This might have to do with the initialization of the "FirebaseApp" in the SDK (?) I'm not really sure. I already tried surrounding the OneSignal.Current.StartInit("app_id").EndInit() in a try-catch but the error/crash still persist.

Environment

  1. 3.5.0
  2. nuget

Steps to Reproduce Issue:

  1. Add version 3.5.0 of the Xamarin SDK to your project
    1. Initialize the SDK with App ID
    2. Run the app (first run/install)

Anything else:


[MonoDroid] Java.Lang.IllegalStateException: Default FirebaseApp is not initialized in this process package_name. Make sure to call FirebaseApp.initializeApp(Context) first.
[MonoDroid]   at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <xxx>:0 
[MonoDroid]   at Java.Interop.JniPeerMembers+JniStaticMethods.InvokeObjectMethod (System.String encodedMember, Java.Interop.JniArgumentValue* parameters) [0x00018] in <xxx>:0 
[MonoDroid]   at Firebase.Iid.FirebaseInstanceId.get_Instance () [0x0000a] in <xxx>:0 
[MonoDroid]   at Microsoft.AppCenter.Push.TokenService.OnTokenRefresh () [0x00005] in <xxx>:0 
[MonoDroid]   at Firebase.Iid.FirebaseInstanceIdService.n_OnTokenRefresh (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <xxx>:0 
[MonoDroid]   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.83(intptr,intptr)
[MonoDroid]   --- End of managed Java.Lang.IllegalStateException stack trace ---
[MonoDroid] java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process package_name. Make sure to call FirebaseApp.initializeApp(Context) first.
[MonoDroid]     at com.google.firebase.FirebaseApp.getInstance(Unknown Source:45)
[MonoDroid]     at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source:0)
[MonoDroid]     at xxx.TokenService.n_onTokenRefresh(Native Method)
[MonoDroid]     at xxx.TokenService.onTokenRefresh(Unknown Source:0)
[MonoDroid]     at com.google.firebase.iid.FirebaseInstanceIdService.zzd(Unknown Source:12)
[MonoDroid]     at com.google.firebase.iid.zzg.run(Unknown Source:24)
[MonoDroid]     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
[MonoDroid]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
[MonoDroid]     at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:7)
[MonoDroid]     at java.lang.Thread.run(Thread.java:764)

[AndroidRuntime] **FATAL EXCEPTION:** Firebase-TokenService
[AndroidRuntime] Process: package_name, PID: ###
[AndroidRuntime] java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process package_name. Make sure to call FirebaseApp.initializeApp(Context) first.
[AndroidRuntime]    at com.google.firebase.FirebaseApp.getInstance(Unknown Source:45)
[AndroidRuntime]    at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source:0)
[AndroidRuntime]    at xxx.TokenService.n_onTokenRefresh(Native Method)
[AndroidRuntime]    at xxx.TokenService.onTokenRefresh(Unknown Source:0)
[AndroidRuntime]    at com.google.firebase.iid.FirebaseInstanceIdService.zzd(Unknown Source:12)
[AndroidRuntime]    at com.google.firebase.iid.zzg.run(Unknown Source:24)
[AndroidRuntime]    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
[AndroidRuntime]    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
[AndroidRuntime]    at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:7)
[AndroidRuntime]    at java.lang.Thread.run(Thread.java:764)
[OneSignal] Device registered, UserId =user_id
srdmnc commented 4 years ago

This issue might be related to this but it is on the OneSignal Android SDK.

srdmnc commented 4 years ago

Anyone there?

Here's another log from App Center

 :   
 at sjh.d(:com.google.android.gms@19420046@19.4.20(120400-271418971): 4)  
 at sjy.a(:com.google.android.gms@19420046@19.4.20(120400-271418971): 47)  
 at qwv.b(:com.google.android.gms@19420046@19.4.20(120400-271418971): 267)  
 at     ... 3 more(: ) Java.Lang.IllegalStateException: Default FirebaseApp is not initialized in this process [package name]. Make sure to call FirebaseApp.initializeApp(Context) first.  
 at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod(Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args)(<215a47b3a1e94f29ba6a610775927d69>: 0)  
 at Java.Interop.JniPeerMembers+JniStaticMethods.InvokeObjectMethod(System.String encodedMember, Java.Interop.JniArgumentValue* parameters)(<215a47b3a1e94f29ba6a610775927d69>: 0)  
 at Firebase.Iid.FirebaseInstanceId.get_Instance()(<8c02bc8ae6d44a47ba32c590764f10f3>: 0)  
 at Microsoft.AppCenter.Push.TokenService.OnTokenRefresh()(<84b4812a3e494bc9b0fa3bea6a4d2785>: 0)  
 at Firebase.Iid.FirebaseInstanceIdService.n_OnTokenRefresh(System.IntPtr jnienv, System.IntPtr native__this)(<8c02bc8ae6d44a47ba32c590764f10f3>: 0)  
 at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.83(intptr,intptr)(: ) java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process [package name]. Make sure to call FirebaseApp.initializeApp(Context) first.  
 at com.google.firebase.FirebaseApp.getInstance(:245)(: ) 
 at com.google.firebase.iid.FirebaseInstanceId.getInstance(:1)(: )  
 at md50d7658ca0fc01b95086956189e698682.TokenService.n_onTokenRefresh(Native Method: )  
 at md50d7658ca0fc01b95086956189e698682.TokenService.onTokenRefresh(:29)(: )  
 at com.google.firebase.iid.FirebaseInstanceIdService.zzd(:6)(: )  
 at com.google.firebase.iid.zzg.run(:4)(: )  
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java: 1167)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java: 641)  
 at com.google.android.gms.common.util.concurrent.zza.run(:6)(: )  
 at java.lang.Thread.run(Thread.java: 919) :   at md50d7658ca0fc01b95086956189e698682.TokenService.n_onTokenRefresh(Native Method: ) :   
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java: 1167)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java: 641) :   
 at java.lang.Thread.run(Thread.java: 919)
rgomezp commented 4 years ago

1) Please include your gradle file 2) Are you using another Firebase project in your app?

srdmnc commented 4 years ago

@rgomezp

  1. This is a Xamarin forms project, there is no Gradle file.
  2. No, I'm not using another Firebase project in my app. (Does Microsoft's App Center count?)
jkasten2 commented 4 years ago

@srdmnc I do see Microsoft.AppCenter.Push.TokenService.OnTokenRefresh in the stacktrace of your crash and not OneSignal. If you don't need to use App Center push with OneSignal at the same time can you disable AppCenter push by removing it or disabling it in another way?

srdmnc commented 4 years ago

@jkasten2 Oh, I missed that. Removing Microsoft.AppCenter.Push solved this issue.

Thanks!