I have an image sitting in my assets directory here:
file:///android_asset/content/images/avatar-img.png
I then create a Uri from that and use it to load it into a Drawable:
String imgFile = "file:///android_asset/content/images/avatar-img.png";
myDrawable.setImageUri(Uri.parse(imgFile));
When this runs I see this in the logs and no image:
W/ImageView(24335): Unable to open content: file:///android_asset/content/images/avatar-img.png
W/ImageView(24335): java.io.FileNotFoundException: /android_asset/content/images/avatar-img.png (No such file or directory)
W/ImageView(24335): resolveUri failed on bad bitmap uri: file:///android_asset/content/images/avatar-img.png
However if I feed the same Uri into my WebView the image loads with no issues:
mWebView.loadUrl(imgFile);
So, we know that:
- The image exist.
- The image is not corrupted.
- The image is readable.
Notes:
- Using BitmapFactory.decodeFile() also fails similarly.
- I've tried adding READ_EXTERNAL_STORAGE permission, but it didn't work.
- I don't see any obvious permission issues in the logs.
Test device:
- Samsung Galaxy S6 Edge
- Android 7.0
- APK min 23, target 26
Thoughts?