Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FirebaseUser's profile is not updated

I use Firebase Auth on Android.

My signin flow works fine but I can't update username & profileUrl right after.

public void test() {
    String username = "test username";
    Uri avatarUri = Uri.parse("http://www.pixelstalk.net/wp-content/uploads/2016/08/Wonderful-Random-Background.jpg");
    UserProfileChangeRequest.Builder builder = new UserProfileChangeRequest.Builder();
    builder.setDisplayName(username);
    builder.setPhotoUri(avatarUri);

    Log.d("UPDATE PROFILE", "user exists=" + (firebaseAuth.getCurrentUser() != null ? "YES" : "NO"));
    Log.d("UPDATE PROFILE", "user anonymous=" + (firebaseAuth.getCurrentUser().isAnonymous() ? "YES" : "NO"));
    firebaseAuth.getCurrentUser().updateProfile(builder.build()).addOnCompleteListener(new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {
            if (task.isSuccessful()) {
                if (firebaseAuth.getCurrentUser().getDisplayName() != null) {
                    Log.d("UPDATE PROFILE", "username=" + firebaseAuth.getCurrentUser().getDisplayName());
                } else {
                    Log.d("UPDATE PROFILE", "username=NULL");
                }
                if (firebaseAuth.getCurrentUser().getPhotoUrl() != null) {
                    Log.d("UPDATE PROFILE", "photoUrl=" + firebaseAuth.getCurrentUser().getPhotoUrl().toString());
                } else {
                    Log.d("UPDATE PROFILE", "photoUrl=NULL");
                }
            } else {
                Log.e("UPDATE PROFILE", task.getException().getMessage());
            }
        }
    });

}

I tried the test method above and this is my output

UPDATE PROFILE: user exists=YES

UPDATE PROFILE: user anonymous=NO

UPDATE PROFILE: username=NULL

UPDATE PROFILE: photoUrl=NULL

I don't understand why my currentUser is not updated even with a "isSuccessful()" result

like image 892
Kyso84 Avatar asked Nov 21 '16 15:11

Kyso84


1 Answers

This is a known issue in the latest release of Firebase (9.8.0). It's a known issue according to here. The only temp fix right now is to rollback everything to version 9.6.1.

Change your gradle dependencies for the app to this for Firebase components (this is just a temp fix, and it could break something else if using something in new version):

compile 'com.google.android.gms:play-services-auth:9.6.1'
compile 'com.google.firebase:firebase-core:9.6.1'
compile 'com.google.firebase:firebase-messaging:9.6.1'
compile 'com.google.firebase:firebase-auth:9.6.1'
compile 'com.google.firebase:firebase-database:9.6.1'

Change those matching ones in your grandle to the versions specified above.

like image 132
Aubtin Samai Avatar answered Oct 28 '22 03:10

Aubtin Samai