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

本文是小编为大家收集整理的关于反应原生安卓发布的apk不能从互联网接收数据的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我在我的设备中开发了一个带有React Native并安装调试APK的应用程序,所有的东西都可以.

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

怎么了?

推荐答案

在我的情况下,我用非安全(http而不是https)调用api.因此,API适用于调试环境,但不能用于发布.您可以添加此行

android:usesCleartextTraffic="true"

androidmanifest.xml

就像那个

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

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

本文地址:https://www.itbaoku.cn/post/1937979.html

问题描述

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

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

what's wrong?

推荐答案

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"

to AndroidManifest.xml

like that

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

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