错误firebase.storage.UploadTask。<init>(未知来源)和firebase.storage.StorageReference.putFile(未知来源)

时间:2017-07-18 09:41:14

标签: android firebase firebase-realtime-database firebase-authentication firebase-storage

错误firebase.storage.UploadTask.<init>(Unknown Source) and firebase.storage.StorageReference.putFile(Unknown Source) ..... 当显示此错误时,则标记ref.putFile(imgUri)。请有人帮助我,我的错误发生了。

        //Get the storage reference
        StorageReference ref = mStorageRef.child(FB_STORAGE_PATH + System.currentTimeMillis() + "." + getImageExt(imgUri));

        //Add file to reference

        ref.putFile(imgUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {


                //Dimiss dialog when success
                dialog.dismiss();
                //Display success toast msg
                Toast.makeText(getApplicationContext(), "Image uploaded", Toast.LENGTH_SHORT).show();
                ImageUpload imageUpload = new ImageUpload(txtImageName.getText().toString(), taskSnapshot.getDownloadUrl().toString());

                //Save image info in to firebase database
                String uploadId = mDatabaseRef.push().getKey();
                mDatabaseRef.child(uploadId).setValue(imageUpload);

            }
        })
                .addOnFailureListener(new OnFailureListener() {
                    @Override
                    public void onFailure(@NonNull Exception e) {

                        //Dimiss dialog when error
                        dialog.dismiss();
                        //Display err toast msg
                        Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
                    }
                })
                .addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {

                    @Override
                    public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {

                        //Show upload progress

                        double progress = (100 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount();
                        dialog.setMessage("Uploaded " + (int) progress + "%");
                    }
                });
    } else {
        Toast.makeText(getApplicationContext(), "Please select image", Toast.LENGTH_SHORT).show();
    }
}

1 个答案:

答案 0 :(得分:0)

只需更新您的Google Play服务,这足以解决此错误。