FirebaseStorage returning unknown error when requesting image

后端 未结 10 782
[愿得一人]
[愿得一人] 2020-12-02 02:05

I am trying to pull in an image I have added to my firebase storage on an Android device. Every time this runs I get this error from the onFailureListener()

相关标签:
10条回答
  • 2020-12-02 02:07

    I just noticed that the httpresult is zero. This suggests the request to get the download url was never made. One way this can happen is if play services isn't updated on your phone. You will know this is the error because adb logcat will show an error with something to the effect of "Storage network layer could not be loaded".

    To fix this, update play services on your phone. There are a few ways of doing this. I find the easiest is to install the app "play services info" to see play services in the play store, and then hit update if its available.

    0 讨论(0)
  • 2020-12-02 02:09

    In my case, I was creating StorageRef from Download URL not with the Storage Location.

    String storageLocation="gs://bbeplayer.appspot.com/heart.png";
        String downloadURL="https://firebasestorage.googleapis.com/v0/b/bbeplayer.appspot.com/o/heart.png?alt=media&token=41a22961-daf1-433e-a580-e65144d34ab3";
        StorageReference reference;
    reference=FirebaseStorage.getInstance().getReferenceFromUrl(downloadURL);
    

    So I changed reference=FirebaseStorage.getInstance().getReferenceFromUrl(downloadURL);

    to

    reference=FirebaseStorage.getInstance().getReferenceFromUrl(storageLocation);
    
    0 讨论(0)
  • 2020-12-02 02:13

    Update Google Play Services on your device, not in your gradle script (though do that, too).

    After banging my head against the wall for about an hour due to only skimming benjamin-wulfe's answer as well as others on the internet, I came back and read it carefully. Hope this will help others avoid my mistake!

    0 讨论(0)
  • 2020-12-02 02:14

    You need upload another file with more size KB, thats work for me!

    0 讨论(0)
  • 2020-12-02 02:19

    I had the same problem ,solution for this is :

    • create a Storage reference-->
    StorageReference storageRef = storage.getReferenceFromUrl("gs:<bucket address>");
    
    • create a child for the storage reference

    StorageReference spaceRef = storageRef.child("child name");

    0 讨论(0)
  • 2020-12-02 02:21

    I got this problem recently and mine was because of the permissions in Firebase Storage i had not allowed read, write in the Rules so i changed them to This Worked for me

    0 讨论(0)
提交回复
热议问题