我正在尝试使用glide:从Firebase存储加载图像
StorageReference storageReference = FirebaseStorage.getInstance().getReference();
StorageReference fileRef = storageReference.child("ProfileIcons/0.png");
Glide.with(getContext()).load(fileRef).into(img_profile_icon);
参考是可以的,图像存在,但它给了我这个错误,照片没有加载:
E/GlideExecutor: Request threw uncaught throwable
com.bumptech.glide.Registry$NoModelLoaderAvailableException: Failed to find any ModelLoaders for model: gs://firestoretest-13873.appspot.com/ProfileIcons/0.png
at com.bumptech.glide.Registry.getModelLoaders(Registry.java:587)
at com.bumptech.glide.load.engine.DecodeHelper.getLoadData(DecodeHelper.java:207)
at com.bumptech.glide.load.engine.DecodeHelper.getCacheKeys(DecodeHelper.java:224)
at com.bumptech.glide.load.engine.ResourceCacheGenerator.startNext(ResourceCacheGenerator.java:44)
at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:310)
at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:276)
at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:431)
W/Glide: Load failed for gs://firestoretest-13873.appspot.com/ProfileIcons/0.png with size [300x300]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
There was 1 cause:
com.bumptech.glide.Registry$NoModelLoaderAvailableException(Failed to find any ModelLoaders for model: gs://firestoretest-13873.appspot.com/ProfileIcons/0.png)
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class com.bumptech.glide.Registry$NoModelLoaderAvailableException: Failed to find any ModelLoaders for model: gs://firestoretest-13873.appspot.com/ProfileIcons/0.png
I/Glide: Root cause (1 of 1)
com.bumptech.glide.Registry$NoModelLoaderAvailableException: Failed to find any ModelLoaders for model: gs://firestoretest-13873.appspot.com/ProfileIcons/0.png
at com.bumptech.glide.Registry.getModelLoaders(Registry.java:587)
at com.bumptech.glide.load.engine.DecodeHelper.getLoadData(DecodeHelper.java:207)
at com.bumptech.glide.load.engine.DecodeHelper.getCacheKeys(DecodeHelper.java:224)
at com.bumptech.glide.load.engine.ResourceCacheGenerator.startNext(ResourceCacheGenerator.java:44)
at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:310)
at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:276)
at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:431)
我检查了一些解决方案,并试图将其添加到我的课堂中,但仍然不起作用:
@GlideModule
public static class MyAppGlideModule extends AppGlideModule {
@Override
public void registerComponents(Context context, Glide glide, Registry registry) {
// Register FirebaseImageLoader to handle StorageReference
registry.append(StorageReference.class, InputStream.class,
new FirebaseImageLoader.Factory());
}
}
请确保遵循文档中列出的所有步骤。您可能会错过添加注释处理器依赖项的步骤:
annotationProcessor 'com.github.bumptech.glide:compiler:4.x'