Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android emulator -dns-server usage

I am currently somewhat struggling to get the Android emulator to use a custom DNS server, which is running on localhost (127.0.0.1).

As of now, I have tried various approaches trying to convince the emulator to use my DNS server, so far without success. In the end, it always boils down to the following error message:

### WARNING: can't resolve DNS server name 'localhost'
### WARNING: will use system default DNS server

localhost, however, resolves correctly when supplied to nslookup:

$ nslookup localhost
Server:  dnszrh01.xxx
Address:  10.xxx.xxx.xxx

Non-authoritative answer:
Name:    localhost.xxx
Address:  127.0.0.1

Using the IP address instead of the hostname also does not help much, it just changes the error message to:

### WARNING: can't resolve DNS server name '127.0.0.1'
### WARNING: will use system default DNS server

The extra command line I am using to start the emulator reads:

-http-proxy http://proxy.xxx:8080 -dns-server 127.0.0.1 -debug-proxy -verbose

This is happening with Android emulator version 5.0 (build_id ECLAIR-24846) running on Windows.

Any hint how to get this working is much appreciated!

like image 893
Thilo-Alexander Ginkel Avatar asked Apr 20 '10 14:04

Thilo-Alexander Ginkel


People also ask

What is Android emulator used for?

An Android emulator is an Android Virtual Device (AVD) that represents a specific Android device. You can use an Android emulator as a target platform to run and test your Android applications on your PC. Using Android emulators is optional.

Is it good to use Android emulator for PC?

Android Emulators are becoming more popular as they provide a good workaround for people who don't have high-end Android devices with good configuration. They also provide access to all mobile applications from PC. Users can play multiple games at a time with good performance.

How much RAM do I need for Android emulator?

o Depending on your computer specs, the recommended ram size is in the range between 512 MB – 1024 MB. Although you can give more ram to the emulator but an actual android device would normally have 512 MB – 1024 MB for ram only.


1 Answers

A couple things...

1) I've noticed I get this error also when I have no network connectivity at all. ie. No wireless or ethernet connection.

2) Excerpt from Emulator guide: http://developer.android.com/guide/developing/tools/emulator.html#dns

Configuring the Emulator's DNS Settings At startup, the emulator reads the list of DNS servers that your system is currently using. It then stores the IP addresses of up to four servers on this list and sets up aliases to them on the emulated addresses 10.0.2.3, 10.0.2.4, 10.0.2.5 and 10.0.2.6 as needed.

On Linux and OS X, the emulator obtains the DNS server addresses by parsing the file /etc/resolv.conf. On Windows, the emulator obtains the addresses by calling the GetNetworkParams() API. Note that this usually means that the emulator ignores the content of your "hosts" file (/etc/hosts on Linux/OS X, %WINDOWS%/system32/HOSTS on Windows).

When starting the emulator at the command line, you can also use the -dns-server option to manually specify the addresses of DNS servers to use, where is a comma-separated list of server names or IP addresses. You might find this option useful if you encounter DNS resolution problems in the emulated network (for example, an "Unknown Host error" message that appears when using the web browser).

3) Also see this other StackOverflow question: Android emulator doesn't use Windows host file?

like image 149
hydrox467 Avatar answered Oct 05 '22 22:10

hydrox467