当我尝试在Android中的ImageView中设置FirebaseStorage图像文件时,对象不是Fount异常

时间:2016-08-09 17:36:23

标签: android imageview picasso firebase-storage

我正在开发一个应用程序,我希望通过使用url将其设置为Imageview来显示来自firebase存储的上传图像。我正在使用以下代码来完成这项工作。

     StorageReference storageReference = FirebaseStorage.getInstance().getReference("ImageFolder/"+imageId);
     storageReference.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
                        @Override
                        public void onSuccess(Uri uri) {  
                          Picasso.with(getContext()).load(uri).into(viewHolder.imageThumbnail);                          
                        }
                    }).addOnFailureListener(new OnFailureListener() {
                        @Override
                        public void onFailure(@NonNull Exception exception) {
                            // Handle any errors
                        }
                    });

这会抛出一个异常,如下所示

已发生StorageException。                                                                     对象在位置不存在。                                                                      代码:-13010 HttpResult:404 08-09 22:50:05.280 10915-11000 / com.app.myapp E / StorageException:{&#34; error&#34;:{&#34; code&#34;:404,&#34; message&#34 ;:&#34;未找到。无法获得对象&#34; }}                                                                     java.io.IOException:{&#34; error&#34;:{&#34; code&#34;:404,&#34; message&#34;:&#34; Not Found。无法获得对象&#34; }}                                                                         在bxr.a(:com.google.android.gms.DynamiteModulesC:424)                                                                         在bxr.a(:com.google.android.gms.DynamiteModulesC:1404)                                                                         at bxl.onTransact(:com.google.android.gms.DynamiteModulesC:53)                                                                         在android.os.Binder.transact(Binder.java:387)                                                                         在com.google.android.gms.internal.zzamj $ zza $ zza.zzss(未知来源)                                                                         在com.google.android.gms.internal.zzamm.zza(未知来源)                                                                         在com.google.android.gms.internal.zzamd.zza(未知来源)

请帮助解决这个问题。

2 个答案:

答案 0 :(得分:0)

当指定位置的firebase存储中没有项目时会发生这种情况。

以下是Android中的异常:

04-13 07:07:48.851 20923-22411/org.emeritus.globalivy E/StorageException: {  "error": {    "code": 404,    "message": "Not Found.  Could not get object"  }}
                                                                          java.io.IOException: {  "error": {    "code": 404,    "message": "Not Found.  Could not get object"  }}
                                                                              at bti.a(:com.google.android.gms.DynamiteModulesC:428)
                                                                              at bti.a(:com.google.android.gms.DynamiteModulesC:1408)
                                                                              at btc.onTransact(:com.google.android.gms.DynamiteModulesC:53)
                                                                              at android.os.Binder.transact(Binder.java:380)
                                                                              at com.google.android.gms.internal.zzbub$zza$zza.zzjM(Unknown Source)
                                                                              at com.google.android.gms.internal.zzbue.zzd(Unknown Source)
                                                                              at com.google.android.gms.internal.zzbtv.zza(Unknown Source)
                                                                              at com.google.android.gms.internal.zzbtv.zze(Unknown Source)
                                                                              at com.google.firebase.storage.zzb.run(Unknown Source)
                                                                              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                                              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

如果Firebase SDK没有将整个堆栈跟踪输出到日志而只有这个

,那就太好了
StorageException has occurred.
                                                                          Object does not exist at location.

答案 1 :(得分:-1)

我有同样的问题,在我的应用程序中,我将数据库中的URL和存储中的图像保存。

只是清理整个STORAGE和DATABAS E的东西,它在我的情况下运作良好。

我发现它发生的原因......

它返回非空 firebase.Promise ,其中包含使用下载网址解析的字符串A Promise,如果提取失败,则拒绝,包括对象是否执行不存在

Check here for this method getDownloadURL()