我已经尝试了几个小时从firebase存储中检索和设置图像,但我似乎就是无法获得它。
我尝试过使用位图和setImageBitmap(),但我的应用程序在加载活动时崩溃。
我也尝试过使用Glide。也会使我的活动崩溃。我尝试使用不同的图像,认为这可能是原因,但仍然崩溃。
我当前的代码是:
mStorageReference = FirebaseStorage.getInstance().getReference().child(photoUrl);
mStorageReference.getDownloadUrl();
Glide.with(this).load(mStorageReference).into(phProfilePhoto);使用依赖关系:
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.firebaseui:firebase-ui-storage:6.3.0'发布于 2020-10-04 08:55:49
因为包含了FirebaseUI (firebase-ui-storage),所以不需要调用getDownloadUrl,可以直接将StorageReference传递到Glide中。
mStorageReference = FirebaseStorage.getInstance().getReference().child(photoUrl);
Glide.with(this).load(mStorageReference).into(phProfilePhoto);如果这会使你的应用崩溃,请编辑你的问题以包含确切的错误消息,并在其logcat输出中包含完整的堆栈跟踪。
https://stackoverflow.com/questions/64190122
复制相似问题