我对Firebase存储的概念还不太了解。
我做了一些研究,找到了这个Glider。可以将图像添加到imageView中。现在它给了我这个错误。
如何解决?
还有其他方法吗?
24 09:39:00.286 14919-14919/azcrew.eatapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: azcrew.eatapp, PID: 14919
java.lang.IllegalArgumentException: Unknown type class com.google.firebase.storage.StorageReference. You must provide a Model of a type for which there is a registered ModelLoader, if you are using a custom model, you must first call Glide#register with a ModelLoaderFactory for your custom model class
at com.bumptech.glide.RequestManager.loadGeneric(RequestManager.java:629)
at com.bumptech.glide.RequestManager.load(RequestManager.java:598)
at azcrew.eatapp.halfdone.Cari$2.onSuccess(Cari.java:76)
at azcrew.eatapp.halfdone.Cari$2.onSuccess(Cari.java:73)
at com.google.android.gms.tasks.zzj.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5696)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
这是代码:
这里是代码
StorageReference mStorageRef = FirebaseStorage.getInstance().getReference();
final StorageReference imgRef = mStorageRef.child("images/img.jpg");
final long ONE_MEGABYTE = 1024*1024;
imgRef.getBytes(ONE_MEGABYTE).addOnSuccessListener(new OnSuccessListener<byte[]>() {
@Override
public void onSuccess(byte[] bytes) {
Glide.with(Cari.this).load(imgRef).diskCacheStrategy(DiskCacheStrategy.ALL).into(kuryerImg);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
}
});