反应原生android发布apk无法从互联网接收数据 [英] react native android release apk can't receive data from Internet

查看:22
本文介绍了反应原生android发布apk无法从互联网接收数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 React Native 开发了一个应用,并在我的设备中安装了调试 apk,一切正常.

I developed an app with React native and install debug apk in my device and all of the things are ok.

但是在我的设备中安装发布版本时,它无法从 API 获取数据.

but when install release version in my device, it can't get data from API.

怎么了?

推荐答案

就我而言,我使用非安全(http 而不是 https)调用 api.所以 api 在调试环境中运行良好,但不适用于发布.你可以添加这一行

In my case, I call api with non secure (http instead of https). So api work well for debug environment, but not work for release. You can add this line

android:usesCleartextTraffic="true"

到 AndroidManifest.xml

to AndroidManifest.xml

那样

<uses-permission android:name="android.permission.INTERNET" />

<application
      ...
      android:usesCleartextTraffic="true"
      ...

这篇关于反应原生android发布apk无法从互联网接收数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆