Android模拟器浏览器和应用程序主机名解析不一致

时间:2022-08-16 18:58:57

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,

我在我的主机(192.168.2.11)上运行了一个Android模拟器,在我的DNS服务器(192.168.2.12)上运行了一个DNS服务器(绑定)。 DNS服务器有我的内部托管应用程序的条目,并使用以下命令调用Android模拟器,

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.

如果我导航到myinternal.domain.com,从Android浏览器,它可以解析域和应用程序加载。但是,当通过应用程序发出HTTP请求时,主机名解析将失败。

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

我甚至试过修改模拟器的/ etc / hosts文件,但没有运气,

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.

我的要求是使用主机名而不是IP地址(默认网站),因此我无法修改代码以将HTTP请求发送到IP地址。

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.

Android浏览器和应用程序是否可能以不同的方式解析主机名?感谢有人可以帮我排除故障。

1 个解决方案

#1


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.

我找到了问题的答案。这种不一致的行为是由于安装的Java版本(在我的例子中是Oracle Java)。用Open-JDK 1.7.80版替换它解决了这个问题。

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

如果其他人正面临这个问题并且不想浪费n个小时,我想考虑发布这个问题:)

#1


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.

我找到了问题的答案。这种不一致的行为是由于安装的Java版本(在我的例子中是Oracle Java)。用Open-JDK 1.7.80版替换它解决了这个问题。

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

如果其他人正面临这个问题并且不想浪费n个小时,我想考虑发布这个问题:)