我尝试使用FirebaseUI提供的令人敬畏的Glide集成,但我无法这样做。
我已按照此处描述的所有内容进行操作:Downloading images with FirebaseUI
无法使用(com.ui.firebase.storage.images.FirebaseImageLoader)解析方法
是我目前得到的错误。
以下是我正在使用的两个库的版本:
Glide 4.0.0-RC1
FirebaseUI 2.0.1
这是我的gradle(应用程序):
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.firebase:geofire-android:2.1.1'
compile 'com.google.android.gms:play-services-location:11.0.1'
compile 'com.android.support:design:25.3.1'
implementation 'com.google.firebase:firebase-database:11.0.1'
implementation 'com.android.support:cardview-v7:25.3.1'
compile 'com.firebaseui:firebase-ui-storage:2.0.1'
compile 'com.github.bumptech.glide:glide:4.0.0-RC1'
compile 'com.android.support:support-v4:25.3.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC1'
implementation 'com.google.firebase:firebase-storage:11.0.1'
implementation 'com.google.firebase:firebase-auth:11.0.1'
}
apply plugin: 'com.google.gms.google-services'
答案 0 :(得分:6)
不幸的是,FirebaseUI尚不支持Glide 4.0,因此您有两个选择:
v3.8.0
此问题正在跟踪:https://github.com/firebase/FirebaseUI-Android/issues/731
编辑:根据上面的链接,问题已在3.0版中解决
答案 1 :(得分:1)
您必须在Gradle依赖项(/app/build.gradle)中包括firebase-ui-storage
,如下所示:
dependencies {
implementation 'com.firebaseui:firebase-ui-storage:6.2.1'
}
检查:last version of this library
然后导入包:
import com.firebase.ui.storage.images.FirebaseImageLoader;
答案 2 :(得分:0)
发生在我身上,我解决了它:
// FirebaseUI for Cloud Storage
implementation 'com.firebaseui:firebase-ui-storage:3.3.0'
// Glide
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
这是需要扩展AppGlideModule的MyAppGlideModule。 覆盖“registerComponents”函数至关重要:
@GlideModule
public final 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());
}
}
实际下载图片的功能:
import com.app.path.where.the.myappglidemodule.is.GlideApp;
"Ex: import com.firebase.uidemo.storage.GlideApp //In case MyAppGlideModule is inside storage package"
public void downloadDirect(StorageReference imageRef, ImageView imageView) {
try {
if (imageRef != null) {
// Download directly from StorageReference using Glide
// (See MyAppGlideModule for Loader registration)
GlideApp.with(this)
.load(imageRef)
.centerCrop()
.transition(DrawableTransitionOptions.withCrossFade())
.into(imageView);
} else {
Log.e(TAG, "Null image storage reference!");
}
}catch (Exception ex){
Log.e(TAG, ex.toString());
}
}