Android - Firebase Quickstart Email/Password Auth Demo Doesn't Work

Android - Firebase Quickstart Email/Password Auth demo doesn't work

The logcat output shows that the creation of the user account is failing. The documentation indicates this can happen for these reasons:

  • the password is not strong enough (less than 6 characters)
  • the email address is malformed
  • there already exists an account with the given email address

Add a Log statement to the completion listener for createUserWithEmailAndPassword() to see what the failure reason is:

@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful());

// If sign in fails, display a message to the user. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in user can be handled in the listener.
if (!task.isSuccessful()) {
Log.d(TAG, "onComplete: Failed=" + task.getException().getMessage()); //ADD THIS

Toast.makeText(EmailPasswordActivity.this, R.string.auth_failed,
Toast.LENGTH_SHORT).show();
}

// [START_EXCLUDE]
hideProgressDialog();
// [END_EXCLUDE]
}

Android Firebase Email and password authentication does not work

You are mixing the legacy SDK:

compile 'com.firebase:firebase-client-android:2.5.2'

with the new SDK:

compile 'com.google.firebase:firebase-auth:10.0.0'

This will cause a number of problems and is the reason for this error message:

Projects created at console.firebase.google.com must use the new Firebase Authentication SDKs available from firebase.google.com/docs/auth/

For new development, you should use only the new SDK. Delete this line from your dependencies:

compile 'com.firebase:firebase-client-android:2.5.2'

The latest versions of FirebaseAuth require additional repositories. Make this change to your project (top-level) build.gradle file:

allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
mavenLocal()
}
}

The change is excerpted from the Firebase Sample project. It will eliminate this error:

Error:Failed to resolve: com.twitter.sdk.android:twitter:2.2.0

Android: createUserWithEmailAndPassword doesn't work (firebase)

try to log the result so you can know what is exactly the problem by using Log.d("FirebaseAuth", "onComplete" + task.getException().getMessage()); it can be because you are not activating the email/password option in the authentication sign-in method or you password is less than 6 characters.

Sample Image

Firebase code not creating new user

If you want to know why creating the user fails, you should display the reason that Firebase Authentication gives you:

if(!task.isSuccessful()){
FirebaseAuthException e = (FirebaseAuthException )task.getException();
Toast.makeText(LoginActivity.this, "Failed Registration: "+e.getMessage(), Toast.LENGTH_SHORT).show();
message.hide();
return;
}

I highly recommend not using toasts to display this type of information, but instead (or additionally) also log it, so that you have a permanent record while developing:

Log.e("LoginActivity", "Failed Registration", e);

Cannot create a user with latest Firebase version. I get a W/DynamiteModule and W/GooglePlayServicesUtil

This is the problem:

W/GooglePlayServicesUtil: Google Play services out of date.  Requires 10084000 but found 9877470

If you running on an emulator, you will need to downgrade to version 9.8.0 or 9.6.1 of the Play Services and Firebase libraries, depending on the API level you are emulating. There is no released emulator image that supports version 10.0.0.

If you are running on a real device, you need to update your version of Google Play Services. The current version is 10.0.84. You can see the version installed on your phone by going to Settings > Application Manager > Google Play services.

This log message is not an indication of a problem. It seems to be output during normal operation:

W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.

Firebase Authentication failing on android emulators due to missing Play Store

Contrary to what I expected, it seems that the Play Store images are only available for some devices.

Mix of virtual devices, with and without the play store in AVD manager

I typically use the "Nexus S" phone and "Nexus 7" tablet for testing, as they have low resolutions and are less resource-intensive. However Google does not seem to support installing the Play Store on either of those images. /p>

To create an emulator with the Play Store pre-installed:

  1. Open the Android Virtual Device (AVD) Manager in Android Studio.
  2. Click on "Create Virtual Device..."
    Create Virtual Device button in AVD Manager
  3. Select one of the small number Pixel Phones that support the Play Store.
    Supported Pixel Phones
  4. Now you will be able to download and use the images with (Play Store) for testing.
    Download Play Store Images
  5. Happy hunting!


Related Topics



Leave a reply



Submit