Open In App

Fresco Image Loading Library in Android with Example

Last Updated : 28 Sep, 2022
Like Article

Fresco is one of the famous image loading libraries from URLs in Android. It is a powerful library for displaying and managing images from URLs. This library can load images from Users’ devices, servers, and other local sources. The most important feature of this library is to show a placeholder image when the image from the URL takes so much time to load. Along with this, we can use an Error image when the image is not being displayed due to any issue. To save data and CPU this library uses three levels of cache out of which two are in memory and one is in internal storage. You can check the official documentation of Fresco.  

Implementation of This Library

A sample image is given below to get an idea about what we are going to do in this article. Note that we are going to implement this project using the Java language. 

Fresco Image Loading Library in Android

Step by Step Implementation

Step 1: Create a New Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language.

Step 2: Add dependency of Fresco Image library in build.gradle file

Navigate to gradle scripts and then to build.gradle(Module) level. Add below line in build.gradle file in the dependencies section.

implementation ‘com.facebook.fresco:fresco:2.3.0’


Add google repository in the build.gradle file of the application project if by default it is not there

buildscript {

 repositories {




All Jetpack components are available in the Google Maven repository, include them in the build.gradle file

allprojects {

 repositories {





Step 3: Add internet permission in the AndroidManifest.xml file

Navigate to the app > Manifest to open the Manifest file. 


<?xml version="1.0" encoding="utf-8"?>
    <!--Permission for internet-->
    <uses-permission android:name="android.permission.INTERNET" />
    <!--Permission for Network State-->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <activity android:name=".MainActivity">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />

Step 4: Create a new SimpleDraweeView in your activity_main.xml

Navigate to the app > res > layout to open the activity_main.xml file. Below is the code for the activity_main.xml file. 


<?xml version="1.0" encoding="utf-8"?>
    <!--To implement ImageView-->
    <!--Constraints are given to align image
        centrally of the view-->
    <!--Scale type center crop is given to
        crop image centrally-->
        app:layout_constraintTop_toTopOf="parent" />

Step 5: Initialize and use SimpleDraweeView in the file

Navigate to the app > java > your apps package name > file. Below is the code for the file. Comments are added inside the code to understand the code in more detail. 


import android.os.Bundle;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.view.SimpleDraweeView;
public class MainActivity extends AppCompatActivity {
    protected void onCreate(Bundle savedInstanceState) {
        // initialize Fresco before setting view.
        // below line is having image url to be added..
        Uri imageUri = Uri.parse("");
        SimpleDraweeView draweeView = (SimpleDraweeView) findViewById(;


Note: In case you are updated to Android Studio 4 you may face this error (NDK at ~/Library/Android/sdk/ndk-bundle did not have a file) during building the project. Please refer to this for fixing the error. 

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads