vihkat
vihkat

Reputation: 1035

Firebase Android Load image to ImageView from storage

I have a Firebase app. Without picasso i want to load uploaded images. I found the next solution:

dependencies {
    // FirebaseUI Storage only
    compile 'com.firebaseui:firebase-ui-storage:0.6.0'
}
// Reference to an image file in Firebase Storage
StorageReference storageReference = ...;

// ImageView in your Activity
ImageView imageView = ...;

// Load the image using Glide
Glide.with(this /* context */)
        .using(new FirebaseImageLoader())
        .load(storageReference)
        .into(imageView);

When i try to use it:

Here is my Firebase Storage URL: gs://teszt-cd548.appspot.com I created an images folder and uploaded cross.png image.

Storage location

gs://teszt-cd548.appspot.com/images/cross.png

When i try to load it on android:

FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl("gs://teszt-cd548.appspot.com");
StorageReference pathReference = storageRef.child("images/cross.png");

Glide.with(context)
       .using(new FirebaseImageLoader())
       .load(pathReference)
       .into(iv);

Here is my rule:

  service firebase.storage {
  match /b/teszt-cd548.appspot.com/o {
    match /{allPaths=**} {
       allow read;
       allow write: if request.auth != null;
    }
  }
}

I got the next error message on android:

StorageException has occurred.
An unknown error occurred, please check the HTTP result code and inner exception for server response.
Code: -13000 HttpResult: 0
01-14 18:42:46.104 31019-31093/com.app.myapplication E/StorageException: null
                    android.os.RemoteException
                        at com.google.android.gms.internal.zzbre.<init>(Unknown Source)
                        at com.google.android.gms.internal.zzbre.zzj(Unknown Source)
                        at com.google.firebase.storage.StorageReference.zzaaN(Unknown Source)
                        at com.google.firebase.storage.StreamDownloadTask.run(Unknown Source)
                        at com.google.firebase.storage.StorageTask$8.run(Unknown Source)
                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                        at java.lang.Thread.run(Thread.java:761)

Anyone have idea about this error?

I hope someone can help me! Thanks so much!

Upvotes: 0

Views: 5092

Answers (1)

Ammar Yasser
Ammar Yasser

Reputation: 148

I had the same error and that happens because your Google play services are out of date my solution is to use a real updated device, you can refer to this question to find more ways to solve your problem and a better explanation.

Upvotes: 1

Related Questions