Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 尝试从Firebase获取文件下载url时发生Firebase错误_Android_Firebase_Android Studio_Firebase Realtime Database_Firebase Storage - Fatal编程技术网

Android 尝试从Firebase获取文件下载url时发生Firebase错误

Android 尝试从Firebase获取文件下载url时发生Firebase错误,android,firebase,android-studio,firebase-realtime-database,firebase-storage,Android,Firebase,Android Studio,Firebase Realtime Database,Firebase Storage,我正在尝试上载一个图像文件,并使用以下代码获取图像下载URL private void UploadImage() { String storageFileName = System.currentTimeMillis() + ".jpg"; // Time is used to ensure unique file name FireBase_File = FireBase_Storage.child(storageFileName); F

我正在尝试上载一个图像文件,并使用以下代码获取图像下载URL

    private void UploadImage() {
    String storageFileName = System.currentTimeMillis() + ".jpg"; // Time is used to ensure unique file name
    FireBase_File = FireBase_Storage.child(storageFileName);

    FireBase_File.putFile(UriBitmap).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
        @Override
        public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
            if(task.isSuccessful()) {
                FireBase_File.getDownloadUrl().addOnCompleteListener(new OnCompleteListener<Uri>() {
                    @Override
                    public void onComplete(@NonNull Task<Uri> task) {
                        if(task.isSuccessful()) {
                            FireBase_DownloadURL = task.getResult().toString();
                        } else { Log.e(Global.Log_Tag + "Manage_Restaurant/UploadImage", "Failed to get download url [Exception]" + task.getException()); }
                    }
                });
            } else { Log.e(Global.Log_Tag + "Manage_Restaurant/UploadImage", "Failed to upload image [Exception]" + task.getException()); }

            Finish_End();
        }
    });
}
private void UploadImage(){
String storageFileName=System.currentTimeMillis()+“.jpg”;//时间用于确保文件名的唯一性
FireBase_File=FireBase_Storage.child(storageFileName);
FireBase_File.putFile(UriBitmap).addOnCompleteListener(新的OnCompleteListener(){
@凌驾
未完成的公共void(@NonNull任务){
if(task.issusccessful()){
FireBase_File.getDownloadUrl().addOnCompleteListener(新的OnCompleteListener(){
@凌驾
未完成的公共void(@NonNull任务){
if(task.issusccessful()){
FireBase_DownloadURL=task.getResult().toString();
}else{Log.e(Global.Log_标记+“Manage_Restaurant/UploadImage”,“无法获取下载url[Exception]”+task.getException());}
}
});
}else{Log.e(Global.Log_标记+“Manage_Restaurant/UploadImage”,“未能上载图像[异常]”+task.getException());}
完成_End();
}
});
}
直到昨天,当我开始在控制台中收到这个错误消息时,它一直工作得很好

E/StorageUtil:获取令牌时出错java.util.concurrent.ExecutionException:com.google.firebase.internal.api.FirebaseNoSignedInUserException:请在尝试获取令牌之前登录

现在我知道以前有人问过这个问题,但我尝试了这个线程所建议的一切,结果都不起作用。还值得注意的是,我没有使用auth firebase系统。我尝试使用匿名登录的建议,它给了我这个错误

com.google.firebase.auth.FirebaseAuthException:此操作仅限于管理员


感谢所有回复

您必须为Firebase项目启用匿名身份验证:


在Firebase控制台中,Auth->Sign-In Methods启用匿名登录方法。

您在Firebase控制台中启用了匿名登录吗?我启用了它并且成功了!非常感谢,我不知道你需要激活它,因为我没有使用身份验证系统。编辑:我无法将此线程设置为已解决。。。所以我不知道该做什么,我把它作为一个答案加上去了