将 Firebase 存储映像与 Glide 配合使用
我几乎尝试了大量重复的答案,但我仍然无法将Firebase存储映像与Glide一起使用。
首先,我正在使用文档
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReference();
StorageReference pathReference = storageRef.child("sorular/1.jpg");
// ImageView in your Activity
ImageView imageView = rootView.findViewById(R.id.imageView);
// Load the image using Glide
Glide.with(this /* context */)
.using(new FirebaseImageLoader()) // Cannot resolve method 'using
.load(pathReference)
.into(imageView);
如果我清理了 Glide 的 .using 部分,logcat 它会给出这个错误:
E/GlideExecutor: Request threw uncaught throwable com.bumptech.glide.Registry$NoModelLoaderAvailableException: Failed to find any ModelLoaders for model: gs://123...appspot.com/sorular/1.jpg
at com.bumptech.glide.Registry.getModelLoaders(Registry.java:227)
at com.bumptech.glide.load.engine.DecodeHelper.getLoadData(DecodeHelper.java:179) at com.bumptech.glide.load.engine.DecodeHelper.getCacheKeys(DecodeHelper.java:197) atcom.bumptech.glide.load.engine.ResourceCacheGenerator.startNext(ResourceCacheGenerator.java:41) at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:282) at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:249) at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:222)
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)
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:347)
那么,如何以最佳方式在我的Android应用程序中使用firebase存储图像呢?
这也是我的构建 gradle 依赖项:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:palette-v7:27.0.2'
implementation "com.android.support:cardview-v7:27.0.2"
implementation "com.android.support:recyclerview-v7:27.0.2"
implementation "com.android.support:support-v4:27.0.2"
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.github.florent37:materialviewpager:1.2.3'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
implementation 'com.firebaseui:firebase-ui-storage:2.0.1'
implementation 'com.google.firebase:firebase-auth:11.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}