Created
June 13, 2019 12:34
-
-
Save densa/f1ba0f332db851313fdd19517aeaa101 to your computer and use it in GitHub Desktop.
[react-native]could not connect to development server on android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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