Search code examples
androiddnsandroid-emulatorhostname

Android emulator browser and application inconsistent hostname resolution


I have an Android emulator running on my host machine (192.168.2.11) and a DNS server (bind) running on my DNS server (192.168.2.12). The DNS server has an entry for my internal hosted application and the Android emulator is invoked with the following command,

emulator @myemulator -scale 0.50 -dns-server 192.168.2.12

From the Android browser if I navigate to myinternal.domain.com, it is able to resolve the domain and the application loads. However, when the HTTP request is made through the application, the hostname resolution fails.

I have even tried by modifying the /etc/hosts file of the emulator but with no luck,

192.168.2.13    myinternal.domain.com
#10.0.2.2       myinternal.domain.com

My requirement is to use hostname than the IP address (default website) so I cannot modify the code to send HTTP requests to the IP address.

Is it possible that the Android browser and the application resolves hostname in a different way? Appreciate if someone can help me out to troubleshoot this.


Solution

  • I found an answer to my problem. This inconsistent behaviour was due to the installed version of Java (Oracle Java in my case). Replacing it with the Open-JDK version 1.7.80 solved the problem.

    Thought to post this in-case if someone else is facing this issue and doesn't want to waste n hours on this :)