Skip to content

Instantly share code, notes, and snippets.

@densa
Created June 13, 2019 12:34
Show Gist options
  • Save densa/f1ba0f332db851313fdd19517aeaa101 to your computer and use it in GitHub Desktop.
Save densa/f1ba0f332db851313fdd19517aeaa101 to your computer and use it in GitHub Desktop.
[react-native]could not connect to development server on android
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
Step 1 : create a file in android folder app/src/debug/res/xml/network_security_config.xml
Step 2 : add this <?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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment