skip to Main Content

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


  1. 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:

    AuthUI authUI = AuthUI.getInstance();
    
    // Change the ip and port accordingly. 
    // I'm using the one mentioned in the docs
    authUI.useEmulator("10.0.2.2", 9099);
    
    Intent intentSignIn = authUI.createSignInIntentBuilder()
                .setAvailableProviders(listProviders)
                .setTheme(R.style.LoginTheme)
                .setLogo(R.drawable.login_icon)
                .setTosAndPrivacyPolicyUrls(
                        "URL",
                        "URL")
                .build();
    

    See if this works.

    Login or Signup to reply.
  2. There are a couple things you can try to get Firebase Auth working on Amazon devices without Google Play Services:

    1. 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.

    2. Configure Auth to use email/password and anonymous sign-in, which do not require Play Services. Avoid Google, Facebook, Twitter providers.

    3. Use the AuthUI component without Play Services using:

    AuthUI.getInstance().createSignInIntentBuilder()
      .setIsSmartLockEnabled(false)
      .setAvailableProviders(Arrays.asList(
          new AuthUI.IdpConfig.EmailBuilder().build(), 
          new AuthUI.IdpConfig.AnonymousBuilder().build())
      .build();
    
    1. Initialize the Firebase App with FirebaseOptions disabled for Auth:
    FirebaseOptions options = new FirebaseOptions.Builder()
      .setApiKey(...)
      .setAppId(...)
      .setAuthEnabled(false) // disable Auth
      .build();
    
    FirebaseApp.initializeApp(context, options);
    
    1. Handle the FirebaseException gracefully and provide an alternative sign-in method.

    2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search