【问题标题】:Apis are not working on old Android devices (Android 7 or less) in React Native using axios but working in new devicesAPI 不能在使用 axios 的 React Native 中的旧 Android 设备(Android 7 或更低版本)上工作,但在新设备上工作
【发布时间】:2021-11-24 05:11:29
【问题描述】:

我使用“axios”库来获取数据。它在新的 Android 设备(Android 9 和 10)上运行完美,但在旧设备(Android 7 或更低版本)上总是出现如下网络错误:[错误:网络错误] 设备似乎无法与https 网址。

这个问题是下面这个链接的重复我也收到这个错误任何人都可以帮忙。

Fix APIs connection problem with old Android OS (Android 7 or less) in React Native using axios

const SERVER_URL = 'https://*****.com/****';

export const getCities = () => async dispatch => {
  let res = await axios.get(`${SERVER_URL}/GetCityList`);
  res = parser.parse(res.data).ArrayOfMCity.mCity;
  if (res && !res.length) {
    res = [res];
  }
  const dropdownCities = [];
  res.forEach(r => {
    dropdownCities.push({label: r.CityName, value: r.CityID});
  });
  dispatch({
    type: GET_CITY,
    payload: {
      cities: res ? res : [],
      dropdownCities,
    },
  });
};

【问题讨论】:

  • 嘿,您是否尝试过共享链接上的解决方案?确保你在之后重建 APK - React native 可能会有点时髦,所以在 Android Studio 中进行以确保。如果这些解决方案不起作用,我们需要查看您的代码和端点
  • 是的,我已经尝试过该链接中给出的解决方案,但没有奏效。问题是它在新的 android 设备上运行良好,但在旧设备上却不行。

标签: javascript android reactjs react-native axios


【解决方案1】:

好吧,我得到了解决方案,我尝试了除我的 api 之外的其他 api,它运行良好。所以我发现我在 android 旧设备中遇到了证书问题。该证书不适用于 7.1 及更早版本的旧设备。

这里的链接表明许多网站将从 2021 年 9 月 1 日起停止在旧版 Android 设备上运行

https://www.androidpolice.com/2020/11/07/many-websites-will-stop-working-on-older-android-versions-in-2021/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-29
    • 2021-01-17
    相关资源
    最近更新 更多