androidreact-nativeandroid-manifestandroid-network-security-config

React Native android:networkSecurityConfig make app can start


I need to use this line

android:networkSecurityConfig="@xml/network_security_config"

inside AndroidManifest because I need to load untrusted website. But it's make my app can not loading by this error:

Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'index.android.bundle' is packaged

enter image description here

Remove this line then app start normally. I dont know why, can someone help me?


Solution

  • this solution worked to me

    <domain includeSubdomains="true">127.0.0.1</domain>
            <domain includeSubdomains="true">localhost</domain>
            <domain includeSubdomains="true">10.0.2.2</domain>
            <domain includeSubdomains="true">10.0.3.2</domain>
    

    https://stackoverflow.com/a/63286158/1308590