My app got rejected from Amazon Appstore due to an error while trying to login with Firebase AuthUI.
I decided to do some research and found out that all Amazon Fire devices run without Google Play Services. I installed a new emulator without Google services and also got an error.
The strange part is, that the version 20.0.0 of the Firebase Auth introduced a feature "The Firebase Authentication Android library now works on devices without Google Play services.".
Code
public void signIn() {
List<AuthUI.IdpConfig> listProviders = Arrays.asList(
new AuthUI.IdpConfig.GoogleBuilder().build(),
new AuthUI.IdpConfig.FacebookBuilder().build(),
new AuthUI.IdpConfig.TwitterBuilder().build(),
new AuthUI.IdpConfig.YahooBuilder().build(),
new AuthUI.IdpConfig.EmailBuilder().build()
);
// Create and launch sign-in intent
Intent intentSignIn = AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(listProviders)
.setTheme(R.style.LoginTheme)
.setLogo(R.drawable.login_icon)
.setTosAndPrivacyPolicyUrls(
"URL",
"URL")
.build();
activityResultLauncherSignIn.launch(intentSignIn);
}
// https://developer.android.com/training/basics/intents/result
private final ActivityResultLauncher<Intent> activityResultLauncherSignIn = registerForActivityResult(
new FirebaseAuthUIActivityResultContract(),
this::onSignInResult
);
private void onSignInResult(FirebaseAuthUIAuthenticationResult firebaseAuthUIAuthenticationResult) {
IdpResponse idpResponse = firebaseAuthUIAuthenticationResult.getIdpResponse();
if (firebaseAuthUIAuthenticationResult.getResultCode() == RESULT_OK) {
if (firebaseUser != null && firebaseUser.getEmail() != null && !firebaseUser.isEmailVerified())
sendVerificationEmail();
} else {
// Sign in failed. If response is null the user canceled the sign-in flow using the back button. Otherwise check response.getError().getErrorCode() and handle the error.
if (idpResponse != null && idpResponse.getError() != null) {
Log.e(TAG, "Problem with Firebase authentication: " + idpResponse.getError().getErrorCode());
}
}
}
Error:
Problem with Firebase authentication: 0
com.google.android.play.core.install.InstallException: -9: Install Error(-9): The Play Store app is either not installed or not the official version.
I am using these dependencies:
implementation platform('com.google.firebase:firebase-bom:32.3.1')
implementation 'com.firebaseui:firebase-ui-auth:8.0.2'
implementation 'com.google.android.gms:play-services-auth:20.7.0'
2
Answers
I was reading the following docs:
So, you need to run the emulator (if running, then ignore) and tell
AuthUI
to use the emulator that you are running.Update the part of your code to this:
See if this works.
There are a couple things you can try to get Firebase Auth working on Amazon devices without Google Play Services:
Use the Firebase Auth emulator during development/testing. This allows you to test Auth without needing an actual device with Play Services. Just be sure to test on an actual Amazon device as well.
Configure Auth to use email/password and anonymous sign-in, which do not require Play Services. Avoid Google, Facebook, Twitter providers.
Use the
AuthUI
component without Play Services using:FirebaseOptions
disabled for Auth:Handle the
FirebaseException
gracefully and provide an alternative sign-in method.Consider using a library like AppAuth for OAuth handling instead of FirebaseUI/Play Services.
With a combination of those approaches, you should be able to support Auth without Play Services on Amazon devices.