I'm using Google authentication through Firebase Auth UI to login users to my app.
In the app I'm developing I've added a sign out button which allow the user to switch the associated Google account.
When the sign out button is clicked an exception is thrown (see observed result section).
I've previously opened a StackOverflow thread on this and was asked to open an issue here.
See this thread: https://stackoverflow.com/questions/48529851/firebase-auth-ui-no-eligible-accounts-can-be-found-error-on-sign-out
The following exception is thrown:
01-30 22:08:39.730 8075-8075/com.ifeins.tenbis E/HomeActivity: signOut: Failed to sign out
java.util.concurrent.ExecutionException: 1 out of 2 underlying tasks failed
at com.google.android.gms.tasks.Tasks$zzc.zzbjb(Unknown Source)
at com.google.android.gms.tasks.Tasks$zzc.onFailure(Unknown Source)
at com.google.android.gms.tasks.zzh.run(Unknown Source)
at com.google.android.gms.tasks.zzm.execute(Unknown Source)
at com.google.android.gms.tasks.zzg.onComplete(Unknown Source)
at com.google.android.gms.tasks.zzl.zzb(Unknown Source)
at com.google.android.gms.tasks.zzn.setException(Unknown Source)
at com.google.android.gms.tasks.TaskCompletionSource.setException(Unknown Source)
at com.google.android.gms.common.internal.zzbl.zzr(Unknown Source)
at com.google.android.gms.common.api.internal.zzs.zzc(Unknown Source)
at com.google.android.gms.common.api.internal.zzs.setResult(Unknown Source)
at com.google.android.gms.internal.zzaul.setResult(Unknown Source)
at com.google.android.gms.internal.zzauk.zze(Unknown Source)
at com.google.android.gms.internal.zzaur.onTransact(Unknown Source)
at android.os.Binder.execTransact(Binder.java:573)
Caused by: com.google.android.gms.common.api.ApiException: 16: No eligible accounts can be found
at com.google.android.gms.common.internal.zzb.zzy(Unknown Source)
at com.google.android.gms.common.internal.zzbk.zzz(Unknown Source)
at com.google.android.gms.common.internal.zzbl.zzr(Unknown Source)
at com.google.android.gms.common.api.internal.zzs.zzc(Unknown Source)
at com.google.android.gms.common.api.internal.zzs.setResult(Unknown Source)
at com.google.android.gms.internal.zzaul.setResult(Unknown Source)
at com.google.android.gms.internal.zzauk.zze(Unknown Source)
at com.google.android.gms.internal.zzaur.onTransact(Unknown Source)
at android.os.Binder.execTransact(Binder.java:573)
I expected the sign out to work successfully and not throw an exception.
This is the sign out code I'm using:
private void signOut() {
AuthUI.getInstance()
.signOut(this)
.addOnCompleteListener((task) -> {
if (task.isSuccessful()) {
User.setCurrentUser(null);
showSignInDialog();
} else {
Log.e(TAG, "signOut: Failed to sign out", task.getException());
}
});
}
This is the code I'm using to perform sign in (notice that I disable smart lock):
private void showSignInDialog() {
List<AuthUI.IdpConfig> providers = Collections.singletonList(
new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build()
);
Intent intent = AuthUI.getInstance()
.createSignInIntentBuilder()
.setIsSmartLockEnabled(false)
.setAvailableProviders(providers)
.build();
startActivityForResult(intent, RC_SIGN_IN);
}
I've also attempted to disable SmartLock on the device itself but the exception is still being thrown.
@ifeins thanks for raising this.
So signOut looks like this:
@NonNull
public Task<Void> signOut(@NonNull Context context) {
mAuth.signOut();
return Tasks.whenAll(
signOutIdps(context),
GoogleApiUtils.getCredentialsClient(context).disableAutoSignIn());
}
and signOutIdps is pretty simple as well:
private Task<Void> signOutIdps(@NonNull Context context) {
try {
LoginManager.getInstance().logOut();
} catch (NoClassDefFoundError e) {
// Do nothing: this is perfectly fine if the dev doesn't include Facebook/Twitter
// support
}
try {
TwitterProvider.signOut(context);
} catch (NoClassDefFoundError e) {
// See comment above
// Note: we need to have separate try/catch statements since devs can include
// _either_ one of the providers. If one crashes, we still need to sign out of
// the other one.
}
return GoogleSignIn.getClient(context, GoogleSignInOptions.DEFAULT_SIGN_IN).signOut();
}
So this is almost definitely coming from the disableAutoSignIn() call.
The good news is that you can safely ignore this error., although it's definitely a pain to detect so we should fix it. I have some ideas for how we can work around it in FirebaseUI but I'm also going to raise this with the SmartLock folks.
@ifeins I bet this comes from disabling SmartLock at the account level on your device, did you see this error before you did that?
Edit: yep that's the trick, I was able to reproduce.
@ifeins fix implemented, will be included in 3.2.2
@samtstern Thanks for the quick turnaround 👍
This issue happened both when SmartLock was enabled and disabled on the device.
This has been fixed and released in version 3.2.2.
@samtstern Thanks for the fix, I had this issue in a side project which I didn't touch for a very long time, so took me a while to verify this. But it's working great now :)
@ifeins thanks for verifying!
Hey guys,
Im using com.firebaseui:firebase-ui-auth:4.2.0 and when I try to login with google I get...
W/SmartLockViewModel: Non-resolvable exception: com.google.android.gms.common.api.ApiException: 16: No eligible accounts can be found.
E/AuthUI: A sign-in error occurred.
Is this still the same issue as above?
Hi,
I get the same error as @aidanmack with version 4.2.0. Any news on that?
Thanks!
@ewaldbenes can you tell me the steps you're using to reproduce?
API Level: 28
Device: Emulator
As the dependencies I use:
implementation 'com.firebaseui:firebase-ui-auth:4.2.0'
implementation 'com.google.firebase:firebase-auth:16.0.4'
implementation 'com.google.android.gms:play-services-auth:16.0.0'
User already exists inside Firebase.
I've got an invisible activity that is my entry point and checks if the user is already signed in. If the user is not then I start the auth flow.
EntryActivity:
override fun onCreate(savedInstanceState: Bundle?) {
...
val auth = FirebaseAuth.getInstance()
if (auth.currentUser != null) {
val intent = Intent(this, MainActivity::class.java)
startActivity(intent)
} else {
startActivityForResult(AuthUI.getInstance()
.createSignInIntentBuilder()
.setIsSmartLockEnabled(false)
.build(), RC_SIGN_IN)
}
}
override fun onPause() {
super.onPause()
finish() // finish() call needed for invisible activities
}
The user gets signed in but the app closes before the result arrives in the EntryActivity.onActivityResult method. When the app is opened again the user is already signed in.
This error shows up in Logcat:
2018-10-29 13:15:01.680 4785-4785/com.example E/AuthUI: A sign-in error occurred.
com.firebase.ui.auth.data.model.UserCancellationException: Unknown error
at com.firebase.ui.auth.data.remote.SignInKickstarter.onActivityResult(SignInKickstarter.java:184)
at com.firebase.ui.auth.KickoffActivity.onActivityResult(KickoffActivity.java:81)
at android.app.Activity.dispatchActivityResult(Activity.java:7454)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4353)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4402)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
2018-10-29 13:15:12.156 4785-4785/com.example E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
2018-10-29 13:15:12.156 4785-4785/com.example E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
I've found this thread here and tried to unset setIsSmartLockEnabled(false) but it didn't help. The error in Logcat is different but the result is the same.
2018-10-29 13:36:46.693 5810-5810/com.example E/AuthUI: A sign-in error occurred.
com.firebase.ui.auth.FirebaseUiException: Error when saving credential.
at com.firebase.ui.auth.viewmodel.smartlock.SmartLockHandler$1.onComplete(SmartLockHandler.java:98)
at com.google.android.gms.tasks.zzj.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: com.google.android.gms.common.api.ApiException: 16: No eligible accounts can be found.
at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(Unknown Source:4)
at com.google.android.gms.common.internal.zai.zaf(Unknown Source:2)
at com.google.android.gms.common.internal.zaj.onComplete(Unknown Source:6)
at com.google.android.gms.common.api.internal.BasePendingResult.zaa(Unknown Source:172)
at com.google.android.gms.common.api.internal.BasePendingResult.setResult(Unknown Source:131)
at com.google.android.gms.common.api.internal.BaseImplementation$ApiMethodImpl.setResult(Unknown Source:36)
at com.google.android.gms.internal.auth-api.zzo.zzc(Unknown Source:4)
at com.google.android.gms.internal.auth-api.zzv.dispatchTransaction(Unknown Source:9)
at com.google.android.gms.internal.auth-api.zzd.onTransact(Unknown Source:12)
at android.os.Binder.execTransact(Binder.java:731)
Then I suspected that the invisibility together with finish()call inside onPause() would be the problem but negative. Indeed the Logcat error is again different.
2018-10-29 13:42:02.087 6287-6287/com.example E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
2018-10-29 13:42:02.087 6287-6287/com.example E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
Using 4.2.1 doesn't solve the issue btw. Together with smart lock unset no error is written in the log.
Pretty interesting that nobody else has fallen across this so far.
Hopefully this descriptions helps. Anyway thanks for your help!
Same problem here
Did this ever get resolved? Having the same issue on api level 28 emulator with similar code.
Most helpful comment
Did this ever get resolved? Having the same issue on api level 28 emulator with similar code.