DEV Community

ochieng seth
ochieng seth

Posted on

Running http requests in release build android react native

For android version 9 and above, http requests wont be successful for your react native apps and this may lead to app crashes simply because RN's networking native module blocks insecure connections by default.
The best solution is to change your api calls to https, however if its a must for you to use http then head over to your main AndroidManifest.xml file and add this line
xmlns:tools="http://schemas.android.com/tools" to the <manifest tag so it looks like so,
<manifest xmlns:tools="http://schemas.android.com/tools">
PS. do not delete any other code inside the <manifest
we aren't done.. head down to the <application tag and add android:usesCleartextTraffic="true" tools:targetApi="28" so it looks like so <application android:usesCleartextTraffic="true" tools:targetApi="28" >
There you have it. Enjoy

Top comments (1)

Collapse
 
hoxon profile image
Leonardo Mangano

Awezome! Thanks