【问题标题】:Image in Firebase Storage doesn't load with PicassoFirebase 存储中的图像无法通过 Picasso 加载
【发布时间】:2017-05-05 01:25:26
【问题描述】:

我正在使用 Firebase 存储Firebase 数据库Picasso,但我遇到了问题。

我的应用将图像上传到 Firebase 存储,然后将 图像下载网址(使用 taskSnapshot.getDownloadUrl().toString()保存在 Firebase 数据库中。

网址如下所示:

"https://firebasestorage.googleapis.com/v0/b/<my-storage-name>.appspot.com/o/Photos%2F40?alt=media&token=<my-token>"

我正在使用 Picasso 接收此链接(var link):

Picasso.with(MainActivity.this).load(link).into(imageView);

我已验证该脚本可以与其他图片网址一起正常工作,但不适用于 Firebase 存储网址。请帮忙

更新

我补充说:

Picasso.with(MainActivity.this).setLoggingEnabled(true);

这是 Android 监视器日志,第一张图片是我的 Facebook 个人资料图片,并且有效:

12-19 23:11:20.279 8710-8710/com.example.john.finality D/Picasso: Main        created      [R8] Request{https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/1465305_691312327560317_1869531162_n.jpg?oh=e86c935ff4945a4573cf75874a095150&oe=58D2344F}
12-19 23:11:20.281 8710-8710/com.example.john.finality D/Picasso: Main        completed    [R8] from MEMORY
12-19 23:11:20.281 8710-8710/com.example.john.finality D/Picasso: Main        created      [R9] Request{https://firebasestorage.googleapis.com/v0/b/<my-storage-name>.appspot.com/o/Photos%2F45?alt=media&token=affebbe7-5a8a-4fc1-bf44-bbb2f971cc01 resize(350,350)}
12-19 23:11:20.282 8710-8952/com.example.john.finality D/Picasso: Dispatcher  enqueued     [R9]+0ms 
12-19 23:11:20.282 8710-8974/com.example.john.finality D/Picasso: Hunter      executing    [R9]+0ms 
12-19 23:11:22.421 8710-8952/com.example.john.finality D/Picasso: Dispatcher  retrying     [R9]+2140ms 
12-19 23:11:22.422 8710-8973/com.example.john.finality D/Picasso: Hunter      executing    [R9]+2140ms 
12-19 23:11:23.525 8710-8952/com.example.john.finality D/Picasso: Dispatcher  retrying     [R9]+3243ms 
12-19 23:11:23.526 8710-8976/com.example.john.finality D/Picasso: Hunter      executing    [R9]+3244ms 
12-19 23:11:23.538 8710-8952/com.example.john.finality D/Picasso: Dispatcher  batched      [R9]+3257ms for error
12-19 23:11:23.771 8710-8952/com.example.john.finality D/Picasso: Dispatcher  delivered    [R9]+3489ms 
12-19 23:11:23.771 8710-8710/com.example.john.finality D/Picasso: Main        errored      [R9]+3489ms 

【问题讨论】:

  • 尝试将监听器放在上面并捕获您遇到的异常并告诉我们。
  • 检查您的存储规则。确保您有足够的权限读取存储区域中的文件。
  • 如果将 URL 粘贴到浏览器窗口会发生什么?如果那不显示图像,毕加索也不会这样做。
  • 嗨朋友们,感谢您的帮助@UMESH0492 检查我的帖子更新
  • @ic90 规则很好,公开

标签: android firebase firebase-realtime-database picasso firebase-storage


【解决方案1】:

我从 Picasso 更改为 Glide 并且效果很好。

分级:

compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'com.android.support:support-v4:24.2.1'

活动:

Glide.with(MainActivity.this).load(link).dontAnimate().into(imageView);

更新

将毕加索更新到 2.5.2 也解决了这个问题。

【讨论】:

    猜你喜欢
    • 2019-10-06
    • 2018-06-27
    • 2015-10-24
    • 2018-06-02
    • 2020-08-03
    • 1970-01-01
    • 2016-12-18
    • 1970-01-01
    • 2017-10-13
    相关资源
    最近更新 更多