Firebase 存储 UI 和 Glide 不显示图像
Firebase Storage UI and Glide not showing images
所以我有一个从 Firebase 存储加载图片的 recyclerview。我使用 Glide 库和 FirebaseImageLoader 来实现这一点。直到上周一,一切都运行良好。图片不再显示,没有任何错误、异常或其他可以帮助我弄清楚为什么图片不再加载的原因:以下是一些代码片段:
Gradle:
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.firebaseui:firebase-ui-storage:1.2.0'
我用来显示图片的ImageView:
<ImageView
android:layout_width="match_parent"
android:layout_height="130dp"
android:id="@+id/imageView_promotions"
android:scaleType="centerCrop"/>
Java 构建 Firebase 存储的代码 link:
public StorageReference getThumbUri(String municipality){
return Constants.STORAGE_REFERENCE.child(Constants.PROMOTIONS).child(municipality).child(promo_thumb);
//returns e.g. gs://myfirebaseapp.com/promotions/Mahikeng/spar_thumb.png
}
加载图像的代码:
Glide.with(context).using(new FirebaseImageLoader()).load(promotions.get(position).
getThumbUri(municipality)).into(holder.imageView_promotions);
P.S。这段代码一直运行良好,从未改变任何我向上帝发誓的东西。我所做的只是将 Android Studio 更新为 2.3.1,并将 Google 支持库更新为 25.3.1
我设法解决了。如果有人遇到同样的问题,请恢复到 Firebase SDK 版本 10.2.1 如果您最近将其更新到 10.2.4,最新的 SDK 似乎存在错误。
一切顺利
我在 Kotlin 中的解决方案:
if (reference != null && reference.isNotEmpty()) {
val storageReference = FirebaseStorage.getInstance().reference.child(reference)
storageReference.downloadUrl.addOnSuccessListener { uri -> Glide.with(context)
.load(uri)
//.centerCrop()
.into(mImage) }
reference 是一个带有文件名的字符串
Gradle:
compile 'com.github.bumptech.glide:glide:4.0.0-RC0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC0'
compile 'com.firebaseui:firebase-ui:2.0.1'
所以我有一个从 Firebase 存储加载图片的 recyclerview。我使用 Glide 库和 FirebaseImageLoader 来实现这一点。直到上周一,一切都运行良好。图片不再显示,没有任何错误、异常或其他可以帮助我弄清楚为什么图片不再加载的原因:以下是一些代码片段:
Gradle:
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.firebaseui:firebase-ui-storage:1.2.0'
我用来显示图片的ImageView:
<ImageView
android:layout_width="match_parent"
android:layout_height="130dp"
android:id="@+id/imageView_promotions"
android:scaleType="centerCrop"/>
Java 构建 Firebase 存储的代码 link:
public StorageReference getThumbUri(String municipality){
return Constants.STORAGE_REFERENCE.child(Constants.PROMOTIONS).child(municipality).child(promo_thumb);
//returns e.g. gs://myfirebaseapp.com/promotions/Mahikeng/spar_thumb.png
}
加载图像的代码:
Glide.with(context).using(new FirebaseImageLoader()).load(promotions.get(position).
getThumbUri(municipality)).into(holder.imageView_promotions);
P.S。这段代码一直运行良好,从未改变任何我向上帝发誓的东西。我所做的只是将 Android Studio 更新为 2.3.1,并将 Google 支持库更新为 25.3.1
我设法解决了。如果有人遇到同样的问题,请恢复到 Firebase SDK 版本 10.2.1 如果您最近将其更新到 10.2.4,最新的 SDK 似乎存在错误。
一切顺利
我在 Kotlin 中的解决方案:
if (reference != null && reference.isNotEmpty()) {
val storageReference = FirebaseStorage.getInstance().reference.child(reference)
storageReference.downloadUrl.addOnSuccessListener { uri -> Glide.with(context)
.load(uri)
//.centerCrop()
.into(mImage) }
reference 是一个带有文件名的字符串
Gradle:
compile 'com.github.bumptech.glide:glide:4.0.0-RC0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC0'
compile 'com.firebaseui:firebase-ui:2.0.1'