Biiiiiird Biiiiiird - 3 months ago 14
Android Question

Android Firebase's createUser failing: handler always calling onError

I'm trying to create a new user in Firebase but onError is constantly being called by my ValueResultHandler:

public void onSignUpComplete(String email, String password) {
Firebase ref = new Firebase(Constants.FIREBASE_URL); // this is "https://subdomain.firebaseio.com/"
ref.createUser(email, password, new SignUpResultHandler());
}

class SignUpResultHandler implements Firebase.ValueResultHandler<Map<String, Object>> {
@Override
public void onSuccess(Map<String, Object> StringObjectMap) {
Toast.makeText(getApplicationContext(), "Created User!", Toast.LENGTH_SHORT().show();
}
@Override
public void onError(FirebaseError firebaseError) {
Toast.makeText(getApplicationContext(), "Failed to create user! " +
firebaseError.getDetails(), Toast.LENGTH_SHORT).show();
}
}


I always get the toast "Failed to create user!" and an empty return from
getDetails()
.

Some extra information: Email and password authentication is enabled in Firebase and my manifest has a uses-permission for
"android.permission.INTERNET"
. I have firebase-auth:9.4.0, firebase-core:9.4.0, firebase-database:9.4.0 and firebase-client-android:2.5.2 as dependencies (and play services). I have my google-services.json file in the app folder and the plugin applied in gradle. I'm running the app in a connected device but this also fails on an emulator.

Answer

Looks like you're following old Firebase documentation. new Firebase() method is deprecated as of May 18, 2016 and the url will be handled by the json file, so we do not need to define it. Here is the link for steps with new documentation: Create a password-based account.

Comments