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.
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.
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:
- Open the Android Virtual Device (AVD) Manager in Android Studio.
- Click on "Create Virtual Device..."
- Select one of the small number Pixel Phones that support the Play Store.
- Now you will be able to download and use the images with (Play Store) for testing.
- Happy hunting!
Related Topics
How to Retrieve More Than 1000 Rows from Parse.Com
Android Toolbar: Small Title Text in Landscape Mode
How to Load a Image from Assets
Center Align Title in Action Bar Using Styles in Android
How to Add "Android Design Support Library" to Eclipse with Adt-Plugin
Mpandroidchart - Adding Labels to Bar Chart
Cordova - Error: Failed to Fetch Platform Android
Android Marshmallow: Changing Permissions at Run Time Crashes App
Android: Is Using Setcontentview Multiple Times Bad While Changing Layouts
Canonical Registration Id and Message Id Format
Out of Memory While Creating Bitmaps on Device
Failure [Install_Failed_Update_Incompatible] Even If App Appears to Not Be Installed
Android Sharedpreferences in Fragment
How to Programmatically Set Maxlength in Android Textview
Want to Compile Native Android Binary I Can Run in Terminal on the Phone
Manage Google Maps API Key with Gradle in Android Studio