android - Glide - 加载失败的图像大小
问题描述
我有以下代码行,Android App
但Glide
拒绝向我显示图像:
requestManager.load(profilePicturePath).into(binding.profilePic)
调试显示profilePicturePath
有值/media/Images/place.jpg
。该文件存在于我的本地Django
开发服务器上。我可以通过PostMan
.
但是在Android
库Glide
中,我收到以下错误消息:
2020-11-22 15:24:08.846 7284-7284/com.example.project W/Glide: Load failed for /media/Images/place.jpg with size [1080x1437]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
There were 3 causes:
java.io.FileNotFoundException(/media/Images/place.jpg (No such file or directory))
java.io.FileNotFoundException(open failed: ENOENT (No such file or directory))
java.io.FileNotFoundException(open failed: ENOENT (No such file or directory))
call GlideException#logRootCauses(String) for more detail
Cause (1 of 3): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, LOCAL
There was 1 cause:
java.io.FileNotFoundException(/media/Images/place.jpg (No such file or directory))
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed
There was 1 cause:
java.io.FileNotFoundException(/media/Images/place.jpg (No such file or directory))
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class java.io.FileNotFoundException: /media/Images/place.jpg (No such file or directory)
Cause (2 of 3): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class android.os.ParcelFileDescriptor, LOCAL
There was 1 cause:
java.io.FileNotFoundException(open failed: ENOENT (No such file or directory))
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed
There was 1 cause:
java.io.FileNotFoundException(open failed: ENOENT (No such file or directory))
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
Cause (3 of 3): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class android.content.res.AssetFileDescriptor, LOCAL
There was 1 cause:
java.io.FileNotFoundException(open failed: ENOENT (No such file or directory))
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
我的问题:
1.) Why is this error happening ?
2.) The image `place.jpg` has the dimension width=316 and height=159 . But Glide states that the image size is [1080x1437]. Why?
解决方案
这是由于范围存储。在 andriod Q 或更高版本中,您无法直接从图像路径访问。您可以使用:
android:requestLegacyExternalStorage="true" android:preserveLegacyExternalStorage="true"
这两个在清单中的应用程序标记中,因此它适用于 android Q,但不适用于下一个版本。您需要实现 Mediastore API
推荐阅读
- python - 如何从未在其中定义“def main”的 Python 文件中导入 main 函数?
- swift - UIPageViewControllerDelegate:'NSInternalInconsistencyException',原因:'无效参数不满足:[views count] == 3'
- c# - 如何打印到下一页溢出的字符串?
- docker - Hyperledger - Docker swarm 在部署到多个主机时失败
- php - 将 php 脚本添加到网站登录/注册功能时出现 HTTP ERROR 500
- mysql - 删除重复的用户元
- python - 使用 python 生成的网页作为 Pygame 控件的输入
- docker - Kubernetes - 如何使用 pod 中目录中的文件?
- infiniband - Infiniband 传输层
- javascript -