Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Reproducible Native App Crash when calling FirebaseAuthentication.signOut() #136

Closed
lincolnthree opened this issue Jul 5, 2022 · 4 comments · Fixed by #149
Closed
Assignees
Labels
bug/fix Something isn't working platform: android Android platform
Milestone

Comments

@lincolnthree
Copy link

lincolnthree commented Jul 5, 2022

Plugin(s):

Firebase Authentication 0.5.0

Platform(s):

Android

Current behavior:

Native Crash to Home Screen

Expected behavior:

Plugin should throw an Error, not crash the Native app (IMO: plugins should never crash the entire app even if something is seriously wrong - unless there's about to be a nuclear security breach or something of that nature.)

Steps to reproduce:

Call FirebaseAuthentication.signOut() regardless of whether or not the user is not signed in via Firebase. This should be a No-Op, not a native crash.

Related code:

insert short code snippets here

Other information:

V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 44981614, pluginId: FirebaseAuthentication, methodName: signOut
V/Capacitor: callback: 44981614, pluginId: FirebaseAuthentication, methodName: signOut, methodData: {}
D/FirebaseAuth: Notifying id token listeners about a sign-out event.
D/FirebaseAuth: Notifying auth state listeners about a sign-out event.
V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 44981615, pluginId: FirebaseAuthentication, methodName: signOut
V/Capacitor: callback: 44981615, pluginId: FirebaseAuthentication, methodName: signOut, methodData: {}
V/Capacitor/FirebaseAuthenticationPlugin: Notifying listeners for event authStateChange
V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 44981616, pluginId: FirebaseAuthentication, methodName: signOut
V/Capacitor: callback: 44981616, pluginId: FirebaseAuthentication, methodName: signOut, methodData: {}
E/Capacitor: Serious error executing plugin
    java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:121)
        at com.getcapacitor.Bridge.lambda$callPluginMethod$0$com-getcapacitor-Bridge(Bridge.java:598)
        at com.getcapacitor.Bridge$$ExternalSyntheticLambda5.run(Unknown Source:8)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.os.HandlerThread.run(HandlerThread.java:67)
     Caused by: The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first.
        at com.facebook.internal.Validate.sdkInitialized(Validate.kt:129)
        at com.facebook.login.LoginManager.<init>(LoginManager.kt:1398)
        at com.facebook.login.LoginManager$Companion.getInstance(LoginManager.kt:1319)
        at com.facebook.login.LoginManager.getInstance(Unknown Source:2)
        at dev.robingenz.capacitorjs.plugins.firebase.authentication.handlers.FacebookAuthProviderHandler.signOut(FacebookAuthProviderHandler.java:69)
        at dev.robingenz.capacitorjs.plugins.firebase.authentication.FirebaseAuthentication.signOut(FirebaseAuthentication.java:272)
        at dev.robingenz.capacitorjs.plugins.firebase.authentication.FirebaseAuthenticationPlugin.signOut(FirebaseAuthenticationPlugin.java:197)
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:121) 
        at com.getcapacitor.Bridge.lambda$callPluginMethod$0$com-getcapacitor-Bridge(Bridge.java:598) 
        at com.getcapacitor.Bridge$$ExternalSyntheticLambda5.run(Unknown Source:8) 
        at android.os.Handler.handleCallback(Handler.java:938) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loopOnce(Looper.java:201) 
        at android.os.Looper.loop(Looper.java:288) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 
E/AndroidRuntime: FATAL EXCEPTION: CapacitorPlugins
    Process: com.maritlabs.topdecked.mtg, PID: 23622
    java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at com.getcapacitor.Bridge.lambda$callPluginMethod$0$com-getcapacitor-Bridge(Bridge.java:607)
        at com.getcapacitor.Bridge$$ExternalSyntheticLambda5.run(Unknown Source:8)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.os.HandlerThread.run(HandlerThread.java:67)
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:121)
        at com.getcapacitor.Bridge.lambda$callPluginMethod$0$com-getcapacitor-Bridge(Bridge.java:598)
        at com.getcapacitor.Bridge$$ExternalSyntheticLambda5.run(Unknown Source:8) 
        at android.os.Handler.handleCallback(Handler.java:938) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loopOnce(Looper.java:201) 
        at android.os.Looper.loop(Looper.java:288) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 
     Caused by: The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first.
        at com.facebook.internal.Validate.sdkInitialized(Validate.kt:129)
        at com.facebook.login.LoginManager.<init>(LoginManager.kt:1398)
        at com.facebook.login.LoginManager$Companion.getInstance(LoginManager.kt:1319)
        at com.facebook.login.LoginManager.getInstance(Unknown Source:2)
        at dev.robingenz.capacitorjs.plugins.firebase.authentication.handlers.FacebookAuthProviderHandler.signOut(FacebookAuthProviderHandler.java:69)
        at dev.robingenz.capacitorjs.plugins.firebase.authentication.FirebaseAuthentication.signOut(FirebaseAuthentication.java:272)
        at dev.robingenz.capacitorjs.plugins.firebase.authentication.FirebaseAuthenticationPlugin.signOut(FirebaseAuthenticationPlugin.java:197)
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:121) 
        at com.getcapacitor.Bridge.lambda$callPluginMethod$0$com-getcapacitor-Bridge(Bridge.java:598) 
        at com.getcapacitor.Bridge$$ExternalSyntheticLambda5.run(Unknown Source:8) 
        at android.os.Handler.handleCallback(Handler.java:938) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loopOnce(Looper.java:201) 
        at android.os.Looper.loop(Looper.java:288) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 

Capacitor doctor:

$ npx cap doctor
💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 3.6.0
  @capacitor/core: 3.6.0
  @capacitor/android: 3.6.0
  @capacitor/ios: 3.6.0

Installed Dependencies:

  @capacitor/cli: 3.6.0
  @capacitor/core: 3.6.0
  @capacitor/android: 3.6.0
  @capacitor/ios: 3.6.0

[success] iOS looking great! 👌
[success] Android looking great! 👌

@lincolnthree
Copy link
Author

This apparently occurs if Facebook has been set up but failed to initialize (for example if the client token is missing.)

@robingenz
Copy link
Member

You're right!

Related to #25.

@robingenz robingenz added platform: android Android platform bug/fix Something isn't working and removed needs: triage labels Jul 13, 2022
@robingenz robingenz self-assigned this Jul 13, 2022
@yuvrajjsingh0
Copy link

Any update? I'm also facing the same issue

@yuvrajjsingh0
Copy link

yuvrajjsingh0 commented Jul 13, 2022

Hey,

I have resolved this by doing following changes to AndroidManifest.xml file inside tag:

<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/fb_app_id"/>
<meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/fb_client_token" />

Now, Facebook SDK will get initialized correctly and error will be resolved. Make sure you put Facbook App id and Facebook Client Token in your strings.xml file

@robingenz robingenz added this to the v0.5.1 milestone Jul 15, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug/fix Something isn't working platform: android Android platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants