gpt4 book ai didi

java - Android glide 在 Android 4.X 中不加载图片

转载 作者:行者123 更新时间:2023-12-02 08:46:48 38 4
gpt4 key购买 nike

我使用 Glide v4.11 从网络加载图片,在 android 5.0 或更高版本中一切正常,但在 android 4.X 中图片无法加载。

这是我的代码:

 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);

这是 Android 4.4 上的 LogCat:

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)

我在网上搜索了一下,发现Android 4.4仅支持TLS 1.0。

这可能是问题所在?如果是的话有什么解决方案吗?

最佳答案

这是一个握手异常。在早于 Android 5.0 的设备上,默认情况下不启用 TLSv1.1TLSv1.2 协议(protocol),这就是发生此异常的原因。

您可以在应用程序类的 onCreate 方法中尝试此操作:

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

此外,您可以查看this github issue以获得更好的解决方案。

关于java - Android glide 在 Android 4.X 中不加载图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61021857/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com