Android Volley: Bad URL in ImageRequest

I’m on Android Studio 4.1.3 (last release). I’m using the Android Volley library and I’m trying to retrieve an image from and API via ImageRequest. The URL that I’m using is the following one:

private String skinUrl = "http://crafatar.com/renders/body/680f95cff25d4f178fea90e2c003bebf.png?size=512&overlay&scale=7"

While using this url in the method

private void requestImage() {
        RequestQueue requestQueue = Volley.newRequestQueue(this);
        ImageRequest imageRequest = new ImageRequest(skinUrl, response -> skin.setImageBitmap(response),
                0,
                0,
                ImageView.ScaleType.CENTER_CROP,
                null,
                error -> {
        });
        requestQueue.add(imageRequest);
    }

I get this error message

NetworkDispatcher.processRequest: Unhandled exception java.lang.RuntimeException: Bad URL 
    java.lang.RuntimeException: Bad URL 
        at com.android.volley.toolbox.NetworkUtility.shouldRetryException(NetworkUtility.java:164)
        at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:145)
        at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:132)
        at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:111)
        at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:90)
     Caused by: java.net.MalformedURLException: no protocol: 
        at java.net.URL.<init>(URL.java:601)
        at java.net.URL.<init>(URL.java:498)
        at java.net.URL.<init>(URL.java:447)
        at com.android.volley.toolbox.HurlStack.executeRequest(HurlStack.java:82)
        at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:104)
        at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:132) 
        at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:111) 
        at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:90) 

I’ve also tried to use the method URLEncoder

skinUrl = URLEncoder.encode(skinUrl);

but the result is the same. The problem is only appening with the ImageRequest, because I’m also retriving json data from another API.

Answer

simple bro use glide image loading library

because its top of android and fast and efficient for image loading just you have to put your image URL and image is load but you have to apply internet permission in manifest.

visit doc – https://github.com/bumptech/glide