Firebaseui-android: Using AppCompatActivity but still using FragmentManager instead of SupportFragmentManager

Created on 29 Jan 2016  Â·  15Comments  Â·  Source: firebase/FirebaseUI-Android

Is there a specific reason why you are not using the support library equivalents of DialogFragment, FragmentManager, etc...?

bug

All 15 comments

The most likely reason is our ignorance. Can you tell what using those would change?

I just realized that you are setting minSdk 16, so I don't think people will run into actual issues. But just to be sure, I have created a pull request that makes use of the support DialogFragment and getSupportFragmentManager. See #67

This definitely needs to be fixed. I'm getting a NullPointerException when logging in via Facebook. This situation may be somewhat unique as I was just experimenting with the library and it had logged out of Google prior to logging in to Facebook.

In any case, you HAVE to import the proper compatibility versions or bad things will happen.

java.lang.NullPointerException at android.app.DialogFragment.dismissInternal(DialogFragment.java:287) at android.app.DialogFragment.dismiss(DialogFragment.java:258) at com.firebase.ui.auth.core.FirebaseLoginDialog$1.onSuccess(FirebaseLoginDialog.java:112) at com.firebase.ui.auth.core.FirebaseAuthProvider$1.onAuthenticated(FirebaseAuthProvider.java:64) at com.firebase.client.authentication.AuthenticationManager$AuthAttempt$2.run(AuthenticationManager.java:91) at android.os.Handler.handleCallback(Handler.java:615) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:155) at android.app.ActivityThread.main(ActivityThread.java:5454) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796) at dalvik.system.NativeStart.main(Native Method)

May also need to change AlertDialog in FirebaseLoginActivity to use android.support.v7.app.AlertDialog.

Hey @rottenscott it seems like you know what you're doing - if you could send in a PR we'd love to learn from it as we're all relatively novice Android devs.

Ha @abehaskins! I think anyone who says they know what they're doing with appcompat is probably fooling themselves. There doesn't seem to be a complete list of compatibility interfaces anywhere you can check so you either have to wade through all the API specs or be really careful when you import in Android Studio to use the correct one.

I don't think minSdk saves you as @Goddchen indicated since in cases like DialogFragment the compatibility version uses a static library regardless of level. So if my app properly imports android.support.v4.app.DialogFragment for it's own dialog and uses the FirebaseUI library which is incorrectly using the framework implementation it ends up using different versions of the FragmentManager which can't be good.

I think @Goddchen has the important fixes in his PR #67 but I will look into AlertDialog changes.

BTW, how are you guys testing provider logins -- the uidemo does not appear to have the necessary IDs/keys set up?

@rottenscott you're right, mixing FragmentManager seems to be a really bad idea. I have updated my PR, FirebaseLoginDialog is now properly using the support components.

@rottenscott What did you do to solve the issue? I'm having the exact same problem. Thanks a lot!
I've only implemented the FB login and the same scenario happened after having successfully logged in.

@Isabellle I only seemed to experience this crash when going through an error path during social login (I don't think all the right setup had been done). In any case you can use @Goddchen PR to run with a version of the library with the necessary fixes -- that's what I am doing.

Thank you @rottenscott

Last question @rottenscott , but I'll have to edit the Jar itself and compile again right? Tricky task for me or maybe can you share your jar with us?

Isabelle,

Sorry I don't have that computer/info in front of me and I haven't worked
on it for a couple of months. Just do a google search on your the build
tools you are using and using github pull (e.g. search "android studio
github pull") and you should find some helpful info about how to set that
up.

I would have hoped that the fine folks from Firebase/Google would have
incorporated these fixes by now!

Good luck!

-Scott
On Apr 8, 2016 8:40 AM, "Isabelle Lepez" [email protected] wrote:

Last question @rottenscott https://github.com/rottenscott , but I'll
have to edit the Jar itself and compile again right? Tricky task for me or
maybe can you share your jar with us?

—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/firebase/FirebaseUI-Android/issues/66#issuecomment-207417094

Thanks a lot for your help ;)

I have the same error above and I changed according to:
[(https://github.com/firebase/FirebaseUI-Android/pull/67/files)]

After the changes, my error message become:

java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.app.FragmentTransaction android.support.v4.app.FragmentManager.beginTransaction()' on a null object reference
at android.support.v4.app.DialogFragment.dismissInternal(DialogFragment.java:196)
at android.support.v4.app.DialogFragment.dismiss(DialogFragment.java:167)
at com.firebase.ui.auth.core.FirebaseLoginDialog$1.onSuccess(FirebaseLoginDialog.java:117)
at com.firebase.ui.auth.core.FirebaseAuthProvider$1.onAuthenticated(FirebaseAuthProvider.java:64)
at com.firebase.client.authentication.AuthenticationManager$AuthAttempt$2.run(AuthenticationManager.java:91)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5549)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)

Seems this will happened when my Facebook app is logged out, and I select Facebook login. After type the credential, the app crashed. (If the Facebook app is logged in and I select Facebook login, I can login without any problem)

What is the reason and is that any solution?
Thanks a lot for your help. :)

Hey all, I am pretty sure this bug only applies to the 0.3.x releases of FirebaseUI. The code was completely rewritten for 0.4.x. I am going to close this issue, if anyone here is using the new library and seeing something similar please create a new issue and I will look into it.

Was this page helpful?
0 / 5 - 0 ratings