UserProfileChangeRequest(java.lang.String, java.lang.String, boolean, boolean)’ is not public in ‘com.google.firebase.auth.UserProfileChangeRequest’. Cannot be accessed from outside package
and
Register.java:85: error: constructor UserProfileChangeRequest in class UserProfileChangeRequest cannot be applied to given types; UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest().Builder().setDisplayName(username).build(); ^ required: String,String,boolean,boolean found: no arguments reason: actual and formal argument lists differ in length
I’m getting the above error from trying to set the display name on registering a user for firebase. How do i solve this?
firebaseAuth.createUserWithEmailAndPassword(email,password).addOnSuccessListener(new O nSuccessListener<AuthResult>() { @Override public void onSuccess(AuthResult authResult) { FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest().Builder().setDisplayName(username).build(); user.updateProfile(profileUpdates); startActivity(new Intent(getApplicationContext(),HomeActivity.class)); finish(); } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Toast.makeText(Register.this, e.getMessage(), Toast.LENGTH_SHORT).show(); } });
Advertisement
Answer
You done some mistakes:
YOUR CODE:
UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest().Builder().setDisplayName(username).build();
CORRECT CODE:
UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder().setDisplayName(username).build();
You have to write new UserProfileChangeRequest.Builder()
instead of new UserProfileChangeRequest().Builder
Remove “()” after UserProfileChangeRequest()
Thanks.