As mentioned by others, you need a couple of things to be able to connect your web-service:
- the emulator to know what is the IP address of the server you need to connect to
- the server name URL you connect through HTTPS must resolve to the domain of the SSL certificate
To do that, you need to:
- mount your emulator partitions
writeable
From your desktop shell (example for linux but would be similar on windows, and assume the Android sdk is intalled on /android-sdk
):
cd /android-sdk/tools/
./emulator -avd NexusS -partition-size 128
where NexusS is the AVD name of your device. You MUST
start the emulator from command line or you will get an error in later steps.
Now open another shell terminal and get your emulator /system/etc/hosts file:
cd /android-sdk/platform-tools
./adb remount
./adb pull /system/etc/hosts /tmp/
The remount
is to set the partitions writeable. The pull
command above copies the hosts file to /tmp/hosts
of your desktop.
From the desktop edit the /tmp/hosts file to match your need, i.e. if the Web Service is https://www.example.com/foo and IP is 192.168.1.10:
127.0.0.1 locahost
192.168.1.10 www.example.com
Then push it back to the emulator:
cd /android-sdk/platform-tools
./adb push /tmp/hosts /system/etc/
You should be able to connect to the web-service now.
Note that you could still have error in case of a self-signed certificate.
The image below is before editing the hosts
file:

After editing:
