描述
React Native应用在iOS上运行正常,但在Android上的Axios网络请求无法正常工作。在Flipper的网络部分,我看不到任何发出或接收到的请求。我不是在本地主机上,所以用10.0.0.2替换它也无法解决问题。我的后端URL类似于http://x.x.x.x:8000/。Java版本为20.0.0.2,Gradle版本为8.3,也尝试了许多其他Java和Gradle版本。希望得到帮助,谢谢。
重现步骤
未提供
React Native版本
0.73.7
受影响的平台
运行时- Android
npx react-native info
的输出
System:
OS: macOS 14.4.1
CPU: (8) arm64 Apple M2
Memory: 97.06 MB / 8.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.10.0
path: ~/.nvm/versions/node/v20.10.0/bin/node
Yarn:
version: 1.22.21
path: ~/.nvm/versions/node/v20.10.0/bin/yarn
npm:
version: 10.2.3
path: ~/.nvm/versions/node/v20.10.0/bin/npm
Watchman:
version: 2024.07.01.00
path: /usr/local/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /usr/local/lib/ruby/gems/3.3.0/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.4
- iOS 17.4
- macOS 14.4
- tvOS 17.4
- visionOS 1.1
- watchOS 10.4
Android SDK:
API Levels:
- "31"
- "33"
- "33"
- "33"
- "34"
- "34"
- "35"
Build Tools:
- 30.0.3
- 33.0.0
- 33.0.1
- 34.0.0
- 35.0.0
System Images:
- android-33 | Google TV ARM 64 v8a
- android-33 | Google Play ARM 64 v8a
- android-34 | Google APIs ARM 64 v8a
- android-35 | Google APIs ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2022.3 AI-223.8836.35.2231.11005911
Xcode:
version: 15.3/15E204a
path: /usr/bin/xcodebuild
Languages:
Java:
version: 20.0.2
path: /Library/Java/JavaVirtualMachines/jdk-20.jdk/Contents/Home/bin/javac
Ruby:
version: 3.0.6
path: /usr/local/opt/ruby@3.0/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.73.7
wanted: ^0.73.7
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false
堆栈跟踪或日志
Error i get in the logcat
AxiosError: Network Error, js engine: hermes, stack:
anonymous@689:2182
dispatchEvent@112:5649
value@105:8861
value@105:4802
anonymous@105:7580
value@23:788
value@10:847
value@39:3897
anonymous@39:693
value@39:2528
value@39:664
?anon_0_@665:625
n@7:69
p@7:317
tryCallOne@53:15
anonymous@139:26
anonymous@100:1667
k@100:498
w@100:888
callReactNativeMicrotasks@100:3058
value@39:2896
anonymous@39:983
value@39:2528
value@39:941
value@39:721
重现者
无
截图和视频
- 无响应*
6条答案
按热度按时间vaj7vani1#
neskvpey2#
0yg35tkg3#
你需要使用https或者在你的AndroidManifest中添加cleartexttrafficpermitted。
1tu0hz3e4#
你需要使用https或者在你的AndroidManifest中添加cleartexttrafficpermitted。我已经这样做了,但是没有帮助。
ss2ws0br5#
这个问题仍然存在。
rxztt3cl6#
问题仍然存在。
重现依然缺失。