-
Notifications
You must be signed in to change notification settings - Fork 0
[Bug] - CredentialApiManager needs Activity context instead of Application context #68
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is needed
Description
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 stackI couldn't give the MainActivity as context to CredentialManager using Koin without breaking modules boundaries.
So need some help on Koin :/
Steps to reproduce:
- Start the app from zero
- Check logs
Or...
- Start the app from zero
- Login with Google or Email auth
- Clear app data and Restart
- Start the app again
- Check logs
-> Expected behaviour:
If the user is logged in before his old account show up with bottom sheet like below

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: 0f2159b0130946f5be5cb847db86db58Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is needed