error firebase.storage.UploadTask.<init>(Unknown Source) and firebase.storage.StorageReference.putFile(Unknown Source)
..... When this error are showing,then its mark the ref.putFile(imgUri). Please someone help me, where my wrong occured.
//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();
}
}
只需更新您的Google Play服务,就足以解决此错误。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.