更新用户信息firebase时出错

时间:2016-08-11 05:25:03

标签: java android firebase firebase-authentication firebase-storage

所以我正在创建一个注册页面并将其与firebase用户连接

我收到错误更新个人资料

我的代码如下:

用于创建新用户我使用

mAuth.createUserWithEmailAndPassword(email, password)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {

                        if (!task.isSuccessful()) {
                            Log.v("SignUp", "222222222222222222222222222");
                            Toast.makeText(SignUp.this, "SignUp failed",
                                    Toast.LENGTH_SHORT).show();
                        } else {
                            Log.v("SignUp", "333333333333333333333333333");
                            uploadImage();

                        }
                    }
                });

并且uploadImage()方法是

public void uploadImage() {
    if (image != null) {
        FirebaseStorage storage = FirebaseStorage.getInstance();
        StorageReference main = storage.getReferenceFromUrl("link to my account");
        StorageReference storageReference = main.child("images/" + image.getLastPathSegment());
        UploadTask uploadTask = storageReference.putFile(image);

        //addonFailurelistener too

        uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                Log.v("SignUp", "777777777777777777777777");
                String download = taskSnapshot.getDownloadUrl().toString();


                UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()
                        .build();
                //i tried here with .setDisplayName(name)
                //and with setPhotoUri(Uri.parse(download)

FirebaseAuth.getInstance().getCurrentUser().updateProfile(profileUpdates).addOnCompleteListener(new OnCompleteListener<Void>() {
                    @Override
                    public void onComplete(@NonNull Task<Void> task) {
                        if (task.isSuccessful()) {
                            Log.v("SignUp", "8888888888888888888888888888");
                            addDatabase();
                        } else {

                       FirebaseAuth.getInstance().getCurrentUser().delete().addOnCompleteListener(new OnCompleteListener<Void>() {
                                @Override
                                public void onComplete(@NonNull Task<Void> task) {
                                    if (task.isSuccessful()) {
                                        Log.v("SignUp", "999999999999999999999999999");
                                        Toast.makeText(SignUp.this, "Error Occuered While setting your account", Toast.LENGTH_LONG);
                                        finish();
                                        startActivity(new Intent(SignUp.this, SignUp.class));
                                    } else {
                                        Log.v("SignUp", "..........................");
                                        Toast.makeText(SignUp.this, "Error Cannot be resolved \n please try with another Email", Toast.LENGTH_LONG);
                                        finish();
                                    }
                                }
                            });
                        }
                    }
                });
            }
        });
}

我的logcat得到像那样的输出

V/SignUp: 333333333333333333333333333
V/SignUp: 777777777777777777777777
V/SignUp: ..........................

我按照了火力指南,但看起来我做错了什么

知道为什么它不起作用?感谢

1 个答案:

答案 0 :(得分:0)

我在等待24小时后自动解决这个问题所以我假设帐户在一天内登录一段时间后被阻止了24小时