i am having difficulties to have my android app running in the emulator to connect to servers in my local network. i am getting a
java.net.UnknownHostException
but the servers are resolvable fine from the machine where the emulator is run.
thanks for any help on this topic!
If you're using Android Studio to run the emulator, then localhost of your host computer will be mapped to the IP address, 10.0. 2.2 , inside the emulator. If you're using other programs to run the emulator, then you may need to consult the documentation associated with those programs.
If your emulator must access the internet through a proxy server, you can configure a custom HTTP proxy from the emulator's Extended controls screen. With the emulator open, click More , and then click Settings and Proxy. From here, you can define your own HTTP proxy settings.
Web traffic is routed through your development machine, so the emulator's external IP is whatever IP has been assigned to that machine by your provider. The development machine can always be reached from your device at 10.0. 2.2.
Then run one of the available emulators with the command, “emulator -avd DEVICE_NAME”, followed by the argument “-dns-server 8.8. 8.8”. This will launch the emulator and overwrite the default DNS server address, replacing it with the address of the primary DNS server for Google DNS.
You have to use 10.0.2.2 to access local server.
Try adding <uses-permission android:name="android.permission.INTERNET" />
to your manifest. This allows your application network access.
More can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With