How do you connect localhost in the emulator or physical device ?
Application (Android)
AndroidManifest.xml
<application
android:networkSecurityConfig="@xml/network_security_config"
</application>
network_security_config.xml
<?xml version="1.0" encoding="utf-8"?> <network-security-config> <domain-config cleartextTrafficPermitted="true"> <domain includeSubdomains="true">IP address</domain> </domain-config> </network-security-config>
Android Studio Emulator
- Open emulator.
- Click on ⋯ to open Extended Controls.
- Go to Settings > Proxy.
- Uncheck Use Android Studio HTTP proxy settings.
- Choose Manual proxy configuration.
- Key in your IP address as host name and the port your backend is running on as port. (e.g. 192.168.1.86:8080)
- Key in the proxy authentication if enabled.
- Click Apply.
Physical Device (Android)
- Open your Android’s Settings.
- Tap Wi-Fi.
- Tap and hold the Wi-Fi Network Name.
- Select Modify Network.
- Click Advanced Options.
- Tap Manual.
- Change your proxy’s settings. Enter the hostname and proxy port. (e.g. 192.168.1.86:8080)
- Tap Save.
Physical Device (iPhone)
- Open your iPhone settings.
- Tap Wi-Fi.
- Select the info icon on the right side.
- Scroll down to the HTTP Proxy Configure Proxy.
- Tap Manual.
- Edit your proxy settings. (e.g. 192.168.1.86:8080)
- Turn on authentication if network IP is not whitelisted in the dashboard and add your Username and Password.
- Tap back to Wi-Fi selection window. This will save your proxy settings.