FirebaseStorage returning unknown error when requesting image

johnsoe picture johnsoe · May 23, 2016 · Viewed 23k times · Source

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()

E/StorageException(9646): An unknown error occurred, please check the HTTP result code and inner exception for server response. E/StorageException(9646): Code: -13000 HttpResult: 0

I have also changed the permissions on storage to have read/write for the time being to make sure that isn't the problem.

final ImageView test = (ImageView) findViewById(R.id.test_image);
StorageReference ref = storage.getReferenceFromUrl("gs://my-project.appspot.com/test_image.png");
    ref.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
        @Override
        public void onSuccess(Uri uri) {
            Log.d(TAG, "Successfully loaded uri");
            test.setImageURI(uri);
        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            Log.d(TAG, "Failed loaded uri: " + e.getMessage());
        }
    });

Answer

Benjamin Wulfe picture Benjamin Wulfe · May 24, 2016

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.