When I run react-native run-android
, it gives me the following error:
Could not connect to development server
Starting with Android 9.0 (API level 28), cleartext support is disabled by default. we can use android:usesCleartextTraffic="true" this will work but this is not recommended solution. For Permanent and recommended Solution is below:
Step 1 : create a file in android folder
app/src/debug/res/xml/network_security_config.xml
Step 2 : add this to network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<!-- deny cleartext traffic for React Native packager ips in release -->
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">localhost</domain>
<domain includeSubdomains="true">10.0.2.2</domain>
<domain includeSubdomains="true">10.0.3.2</domain>
</domain-config>
</network-security-config>
Step 3 : Apply the config to your AndroidManifest.xml
<application
android:networkSecurityConfig="@xml/network_security_config">
</application>
Make sure NPM server is running. Else run it again. It will solve the issue.
For me i have uninstalled a package that i recently installed and the project ran again on my physical device using the following command "npm uninstall recentPackageName" hope this helps :)
In my case, running on a Macbook, i had to turn off my firewall, thus allowing incoming connections from my android. RN v0.61.5
We faced this issue, In order to fix this, solution is dead simple is below.
Basically this error tells that your current build got failed due to reasons like Code issue or dependency issue.
Click here for more details
Found the issue with Android X device.
For Android API 28 and above
In network_security_config.xml with cleartextTrafficPermitted="true"
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
....
</domain-config>
</network-security-config>
Then, reload JS