Android glide not loading pictures in Android 4.X

0

I am using Glide v4.11 to load pictures from the web , everything work fine in android 5.0 or higher but in android 4.X pictures do not load.

Here is my code :

 RequestOptions options = new RequestOptions()
                    .placeholder(android.R.drawable.progress_horizontal)
                    .error(android.R.drawable.presence_offline)
                    .diskCacheStrategy(DiskCacheStrategy.ALL);

   Glide.with(context)
                    .load(data.getImage_url())
                    .apply(options)
                    .into(holder.thumbnail);

and here is the LogCat on Android 4.4:

W/Glide: Load failed for https://www.gradientapi.xyz/generate/w/1000/h/500 with size [188x263]
    class com.bumptech.glide.load.engine.GlideException: Failed to load resource
    There was 1 cause:
    javax.net.ssl.SSLHandshakeException(javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb85422a0: Failure in SSL library, usually a protocol error
    error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:766 0xa744e990:0x00000000))
     call GlideException#logRootCauses(String) for more detail
      Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, REMOTE
    There was 1 cause:
    javax.net.ssl.SSLHandshakeException(javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb85422a0: Failure in SSL library, usually a protocol error
    error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:766 0xa744e990:0x00000000))
     call GlideException#logRootCauses(String) for more detail
        Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed
    There was 1 cause:
    javax.net.ssl.SSLHandshakeException(javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb85422a0: Failure in SSL library, usually a protocol error
    error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:766 0xa744e990:0x00000000))
     call GlideException#logRootCauses(String) for more detail
          Cause (1 of 1): class javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb85422a0: Failure in SSL library, usually a protocol error
    error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:766 0xa744e990:0x00000000)

I searched over web and i found that Android 4.4 only support TLS 1.0.

It may be the issue ? and if yes is there any solutions ?

java
android
android-glide
asked on Stack Overflow Apr 3, 2020 by anehme • edited Jul 6, 2020 by Zoe

1 Answer

1

It's a handshake exception. On devices older than Android 5.0 TLSv1.1 and TLSv1.2 protocols are not enabled by default and that's why this exception occurs.

You can try this inside your Application's class onCreate method:

if (Build.VERSION.SDK_INT == 19) {
        try {
            ProviderInstaller.installIfNeeded(this);
        } catch (Exception ignored) {
        }
    }

Also, You can check this github issue for better solutions.

answered on Stack Overflow Apr 3, 2020 by Mohamed Nageh

User contributions licensed under CC BY-SA 3.0