我的应用崩溃导致错误通道无法恢复,将被销毁

时间:2019-11-01 09:27:53

标签: android firebase firebase-storage

此代码在Firebase存储中创建引用并将图像保存在存储中,然后在数据库中保存文本和图像URL。 它可以在我的一部手机(API 28)上正常运行,但在另一部手机(API 25)上崩溃。

我检查了先前对类似问题的查询,但没有具体说明。

private void uploadImage(final Uri imageFile) {
        progressDialog = new ProgressDialog(this);
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progressDialog.setTitle("Uploading File");
        progressDialog.setProgress(0);
        progressDialog.show();

        storageReference.child("Users").child(Objects.requireNonNull(auth.getCurrentUser()).getUid()).child(f_name.getText().toString()+" "+ l_name.getText().toString()).putFile(imageFile).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {

                String du = Objects.requireNonNull(taskSnapshot.getUploadSessionUri()).toString();
                Log.i("session url ", du);
                String du1 = du.substring(0, du.indexOf("&uploadType"));
                String du3 = "&alt=media";
                downloadUrl = du1 + du3;
                Log.i("download url url ", downloadUrl);

            }
        }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                Toast.makeText(Info.this, "Inside failure listener failed to store file", Toast.LENGTH_SHORT).show();
            }
        }).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onProgress(@NonNull UploadTask.TaskSnapshot taskSnapshot) {
                int currentProgress = (int) (100 * taskSnapshot.getBytesTransferred() / taskSnapshot.getTotalByteCount());
                progressDialog.setProgress(currentProgress);

            }
        });
databaseReference.child("Users").child(Objects.requireNonNull(auth.getCurrentUser()).getUid()).child("Name").setValue(f_name.getText().toString()+" "+ l_name.getText().toString());
        databaseReference.child("Users").child(auth.getCurrentUser().getUid()).child("Profile Image").setValue(downloadUrl);

错误:

Channel is unrecoverably broken and will be disposed!
could not obtain extracted text (class com.touchtype.keyboard.c.aj)

0 个答案:

没有答案