gpt4 book ai didi

android - React Native Android - 图像组件(网络) - 不会通过 https 加载

转载 作者:太空狗 更新时间:2023-10-29 14:51:15 25 4
gpt4 key购买 nike

我在通过 https 加载任何图像时遇到问题。我使用的是 React Native 0.18,实现非常简单,例如在 Amazon 使用图像:

将起作用:

<Image style={styles.avatar} source={{uri: "http://ecx.images-amazon.com/images/I/71JxCVQ5ozL.jpg"}} />

无效:

<Image style={styles.avatar} source={{uri: "https://images-na.ssl-images-amazon.com/images/I/41KoE8etwlL.jpg"}} />

有没有人看到这个?

感谢您的帮助。

最佳答案

遇到了类似的问题。我的是因为某些站点使用的 SSL/TSL 版本以及它们与旧版 android 操作系统 (TLS v1.2) 的问题。来自特定站点的图像会显示在模拟器上,但不会显示在实际的 Android 设备上。

  1. 我使用 Image 的 onError 方法来记录实际错误。请注意,如果您使用网络调试器,您将不会看到此错误。

          onError={e => {
    console.log(e);
    }}
  2. 查看了 Android Debug Bridge (ADB) 上记录的实际错误,错误是:

    “错误:javax.net.ssl.SSLProtocolException:SSL 握手中止:”

显然这是旧版 Android 操作系统的问题。

我点击了链接 here解决 ssl 问题。现在完美运行

请注意,对于某些 React Native 版本,Image 组件的 onError 方法不会在 Android 设备上触发。您可以使用 here 中的 polyfill“react-native-android-image-polyfill”

关于android - React Native Android - 图像组件(网络) - 不会通过 https 加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35142654/

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