java - 平板电脑上 api 22(5.1.1) 的毕加索缓存错误
问题描述
我在 recyclerview 中使用 picasso,如下所示:
Picasso.with(context).load(contects.get(position).getLogo()).memoryPolicy(MemoryPolicy.NO_CACHE )
.networkPolicy(NetworkPolicy.NO_CACHE).error(R.mipmap.ic_launcher).into(holder.ImageView);
但我在毕加索日志上得到了这个:
D/Picasso: Main created [R0] Request{https://debo3.com/wp- content/uploads/2017/08/abstract-logo-template_1331-33.jpg}
D/Picasso: Dispatcher enqueued [R0]+11ms
D/Picasso: Hunter executing [R0]+14ms
D/Picasso: Main created [R1] Request{https://debo3.com/wpcontent/uploads/2017/08/abstract-logo-template_1331-33.jpg}
D/Picasso: Hunter joined [R1]+1ms to [R0]+17ms, [R1]+1ms
W/System.err: remove failed: ENOENT (No such file or directory) : /data/data/com.example.ahmadi.khadamat/cache/picasso-cache/journal.tmp
D/Picasso: Main created [R2] Request{https://debo3.com/wp-content/uploads/2017/08/abstract-logo-template_1331-33.jpg}
D/Picasso: Hunter joined [R2]+1ms to [R0]+21ms, [R1]+5ms, [R2]+1ms
D/Picasso: Dispatcher retrying [R0]+20s, [R1]+20s, [R2]+20s
D/Picasso: Hunter executing [R0]+20s, [R1]+20s, [R2]+20s
D/Picasso: Dispatcher retrying [R0]+41s, [R1]+41s, [R2]+41s
D/Picasso: Hunter executing [R0]+41s, [R1]+41s, [R2]+41s
D/Picasso: Dispatcher batched [R0]+41s, [R1]+41s, [R2]+41s for error
D/Picasso: Dispatcher delivered [R0]+42s, [R1]+42s, [R2]+42s
D/Picasso: Main errored [R0]+42s
D/Picasso: Main errored [R1]+42s
D/Picasso: Main errored [R2]+42s
我认为错误就在这一行:
W/System.err: remove failed: ENOENT (No such file or directory) : /data/data/com.example.ahmadi.khadamat/cache/picasso-cache/journal.tmp
它适用于所有 android 版本,但不适用于 android 5.1.1 (tablet) (api 22)
解决方案
添加此代码:
.memoryPolicy(MemoryPolicy.NO_STORE)
.networkPolicy(NetworkPolicy.NO_STORE)
推荐阅读
- c# - 与 System.Text.Json.JsonException 苦苦挣扎的 GraphQL 模型
- javascript - JavaScript 异步/等待策略,函数提前解析/等待不等待
- python - 如何在没有任何模块的情况下从python3中的列表中获取随机项
- java-11 - 在 Linux 系统上使用 Apache FOP JDK 11 来自 sun.awt.FontConfiguration.getVersion 的 NPE
- ios - Xcode 错误:“团队未注册 Apple Developer Program xcode 分发”
- python - 如何返回保存在数据库中的图像(Flask)
- c++ - 如何检查一个数字是否在多维数组中重复?
- django - 使用 XLSXWRITER 时出现 Django SyntaxError
- c# - 在 C# 中使用 aspose.words 从 word 文档中提取 2 个字符串之间的文本
- mysql - mysql_config_path 在 WSL2 中找不到 Ubuntu 18.04 发行版