stevdza-san / OneTapCompose

This library allow you to easily integrate One-Tap Sign in with Google(Credential Manager) in your project with Jetpack Compose. It keeps away all the boilerplate code.
Apache License 2.0
176 stars 15 forks source link

FragmentContextWrapper cannot be cast to android.app.Activity #4

Closed Cerverussz closed 1 year ago

Cerverussz commented 1 year ago

calling OneTapSignInWithGoogle from a fragment gives this error

java.lang.ClassCastException: dagger.hilt.android.internal.managers.ViewComponentManager$FragmentContextWrapper cannot be cast to android.app.Activity

image

stevdza-san commented 1 year ago

I've made this library primarily for usage with Compose Activity. I haven't actually tested it with Fragments. You can check the source code and try to experiment with it a bit. :)

Cerverussz commented 1 year ago

Yes sir, the solution was:

add the context as a parameter and from the fragment, it is sent as requireActivity()

Thank you very much and see you soon :D