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] - CredentialApiManager needs Activity context instead of Application context #68

Open
eneskyilmaz opened this issue Dec 25, 2023 · 0 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@eneskyilmaz
Copy link
Collaborator

eneskyilmaz commented Dec 25, 2023

Describe the issue:

CredentialApiManager uses Application context which is defined in LoginModule.
It uses Koin's androidApplication() as context.
But CredentialManager needs context thats related to UI.
As it says on inline comments on CredentialManager.kt ->

     * @param context the context used to launch any UI needed; use an activity context to make
     * sure the UI will be launched within the same task stack

I couldn't give the MainActivity as context to CredentialManager using Koin without breaking modules boundaries.

So need some help on Koin :/

Steps to reproduce:

  1. Start the app from zero
  2. Check logs

Or...

  1. Start the app from zero
  2. Login with Google or Email auth
  3. Clear app data and Restart
  4. Start the app again
  5. Check logs

-> Expected behaviour:

If the user is logged in before his old account show up with bottom sheet like below
image

Stacktrace:

01:33:11.684 CredentialApiManager                 D  An error occurred. Please try again later. (Ask Studio Bot)
                                                     androidx.credentials.exceptions.GetCredentialUnknownException: Failed to launch the selector UI. Hint: ensure the `context` parameter is an Activity-based context.
                                                     	at androidx.credentials.playservices.controllers.BeginSignIn.CredentialProviderBeginSignInController$invokePlayServices$1.invoke$lambda$0(CredentialProviderBeginSignInController.kt:128)
                                                     	at androidx.credentials.playservices.controllers.BeginSignIn.CredentialProviderBeginSignInController$invokePlayServices$1.$r8$lambda$DhvsFEnWMMxm9GESQg_0D0GOVJc(Unknown Source:0)
                                                     	at androidx.credentials.playservices.controllers.BeginSignIn.CredentialProviderBeginSignInController$invokePlayServices$1$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
                                                     	at androidx.credentials.CredentialManager$$ExternalSyntheticLambda0.execute(D8$$SyntheticClass:0)
                                                     	at androidx.credentials.playservices.controllers.BeginSignIn.CredentialProviderBeginSignInController$invokePlayServices$1.invoke(CredentialProviderBeginSignInController.kt:126)
                                                     	at androidx.credentials.playservices.controllers.BeginSignIn.CredentialProviderBeginSignInController$invokePlayServices$1.invoke(CredentialProviderBeginSignInController.kt:126)
                                                     	at androidx.credentials.playservices.controllers.CredentialProviderController$Companion.cancelOrCallbackExceptionOrResult(CredentialProviderController.kt:136)
                                                     	at androidx.credentials.playservices.controllers.CredentialProviderController.cancelOrCallbackExceptionOrResult(Unknown Source:2)
                                                     	at androidx.credentials.playservices.controllers.BeginSignIn.CredentialProviderBeginSignInController.invokePlayServices(CredentialProviderBeginSignInController.kt:126)
                                                     	at androidx.credentials.playservices.CredentialProviderPlayServicesImpl.onGetCredential(CredentialProviderPlayServicesImpl.kt:70)
                                                     	at androidx.credentials.CredentialManagerImpl.getCredentialAsync(CredentialManagerImpl.kt:134)
                                                     	at androidx.credentials.CredentialManager.getCredential$suspendImpl(CredentialManager.kt:132)
                                                     	at androidx.credentials.CredentialManager.getCredential(Unknown Source:0)
                                                     	at dev.enesky.core.domain.manager.CredentialApiManager.getCredentials(CredentialApiManager.kt:71)
                                                     	at dev.enesky.core.domain.manager.AuthManager.getCredentials(AuthManager.kt:336)
                                                     	at dev.enesky.feature.login.signin.SignInViewModel.signInWithCredentialApi(SignInViewModel.kt:43)
                                                     	at dev.enesky.feature.login.signin.SignInViewModel.access$signInWithCredentialApi(SignInViewModel.kt:26)
                                                     	at dev.enesky.feature.login.signin.SignInViewModel$2.invokeSuspend(SignInViewModel.kt:36)
                                                     	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                     	at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:235)
                                                     	at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:168)
                                                     	at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:474)
                                                     	at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:508)
                                                     	at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:497)
                                                     	at kotlinx.coroutines.CancellableContinuationImpl.resumeUndispatched(CancellableContinuationImpl.kt:595)
                                                     	at kotlinx.coroutines.android.HandlerContext$scheduleResumeAfterDelay$$inlined$Runnable$1.run(Runnable.kt:19)
                                                     	at android.os.Handler.handleCallback(Handler.java:938)
                                                     	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                     	at android.os.Looper.loopOnce(Looper.java:226)
                                                     	at android.os.Looper.loop(Looper.java:313)
                                                     	at android.app.ActivityThread.main(ActivityThread.java:8751)
                                                     	at java.lang.reflect.Method.invoke(Native Method)
                                                     	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
                                                     	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
01:33:11.689 SessionLifecycleClient               D  Session update received: 0f2159b0130946f5be5cb847db86db58
@eneskyilmaz eneskyilmaz self-assigned this Dec 25, 2023
@eneskyilmaz eneskyilmaz added bug Something isn't working help wanted Extra attention is needed labels Dec 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant