Show images inside assets folder with fresco

fresco-logo

fresco is an image management library for Android development, developed by Facebook.

Often times when you use fresco just like a simple ImageView you would put SimpleDraweeView inside your xml and call setImageURI from Java code.

This flow is intuitively easy and it works for fetching and displaying images from network, but somehow I struggled for several hours to figure out the way to show images inside assets directory; fresco never showed the images for me without any erorr.

It turns out, when you use fresco to show images inside assets folder, you must specify the image URI with the following format:

asset:///your-image-file-name (e.g. asset:///my_adorable_cat.jpg)

Note that it’s not assets but asset and it has :/// instead of ://!

You should be aware of that if you are considering using fresco! :)