簡體   English   中英

react-native expo android macos問題

[英]react-native expo android macos issue

我在 android 上遇到了 react-native 應用程序的問題,

  • 應用程序是使用 expo 構建的

  • 該應用程序在 iOS 設備以及 iOS 模擬器上運行良好

  • 在 android 模擬器上運行,它在啟動時給出警告。

可能未處理的 Promise 拒絕(id:0):

TypeError:網絡請求失敗

附上來自模擬器的錯誤圖像

  • 任何后續調用fetch掛起並出現以下錯誤

[未處理的 promise 拒絕:TypeError:網絡請求失敗]

  • setTimeout$argument_0 中的 node_modules/whatwg-fetch/dist/fetch.umd.js:535:17
  • _callTimer 中的 node_modules/react-native/Libraries/Core/Timers/JSTimers.js:130:14
  • node_modules/react-native/Libraries/Core/Timers/JSTimers.js:383:16 in callTimers
  • __callFunction 中的 node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:416:4
  • __guard$argument_0 中的 node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:109:6
  • __guard 中的 node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:364:10
  • node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:108:4 in callFunctionReturnFlushedQueue
  • 【原生代碼】:null in callFunctionReturnFlushedQueue

fetch 調用是對 https 進行的,但是,在閱讀了網上的幾篇文章后,我在 app.json 中添加了以下內容,但沒有效果

"android": {
   "UsesCleartextTraffic": "true"
}

下面列出了來自 package.json 的應用程序依賴項

  "dependencies": {
    "@react-native-community/hooks": "^2.6.0",
    "expo": "~39.0.2",
    "expo-status-bar": "~1.0.2",
    "graphql": "^14.7.0",
    "graphql-request": "^3.3.0",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-39.0.4.tar.gz",
    "react-native-maps": "^0.27.1",
    "react-native-web": "~0.13.12"
  },

關於可能是什么問題的任何幫助?

在此處輸入圖像描述

終於想通了……

這可能有助於其他嘗試從您在 Android 模擬器中運行的應用程序連接到 VPN 中的端點的人

Android 模擬器有自己的網絡堆棧,如果您的應用程序嘗試連接到 VPN 中的端點,您必須執行以下操作

  1. 獲取安裝了 Google Play 商店的 android 設備映像。

  2. 在 Android 映像上下載並安裝您選擇的 VPN 工具

  3. 在android仿真器中啟動VPN

  4. 現在,您在模擬器上的應用可以連接到受保護的 VPN 端點。

僅在您的主機上運行 VPN 是不夠的,您需要在模擬器本身上運行 VPN...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM