简体   繁体   English

无法在 android release apk 上发送 http 请求(内置 react-native)

[英]can't send http request on android release apk (built in react-native)

I am sending an HTTP request with dummy username and password to test the my App.我正在发送一个带有虚拟用户名和密码的 HTTP 请求来测试我的应用程序。

On working with non-release variants ie react-native run-android , I am capable of sending http requests to the server and receive a token, thus, logging in. However, this is not true when I try it on the release version of the apk react-native run-android --variant=release在使用非发布变体即react-native run-android ,我能够向服务器发送 http 请求并接收令牌,从而登录。但是,当我在发布版本上尝试时,情况并非如此apk react-native run-android --variant=release

Note: It allow works on ios after making注意:它允许在制作后在 ios 上工作

<key>NSAllowsArbitraryLoads</key>
        <true/>

You must add the following code to AndroidManifest.xml file to allow http requests.您必须将以下代码添加到AndroidManifest.xml文件以允许 http 请求。

android:usesCleartextTraffic="true"

For more information look at this question有关更多信息,请查看此问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM