No network in VirtualBox (Android) - android

I am unable to set up a network connection on my Android emulator using VirtualBox. I followed multiple posts that tell me to set the adapter to Bridged or NAT.
When I execute netcfg in the console while the Android is running, the following lines show:
lo UP 127.0.0.1 255.0.0.0 0x0000049
eth0 UP 0.0.0.0 0.0.0.0 0x0001003
I need the left address from eth0 to use in Eclipse. Any tips how I can configure my internet?
edit:
It has to do that I'm using a wireless laptop. Are there any ways around to enable a faster emulator on Eclipse than the default one provided by Google?

If you set the adapter to NAT you must set your network configuration to DHCP, but if you want set the adapter to Bridged set your network configuration manually according to your network.
Maybe isn't a network problem and it's a ISO image problem, check this question:
How to set up network on VirtualBox for Android 2.3

Related

Genymotion overrides dhcp of virtualbox network adapter

I am running an android image with genymotion 2.8.0 and virtualbox 5.0.28 on osx. My network has a router with dhcp 192.168.1.1 and I want to access my host system (the mac) from android by using 10.0.2.3 or the IP of the MAC. The problem is that the virtual network adapter is always getting an ip in the wrong net vboxnet1 => inet 192.168.57.1
Therefore I tried to changed the interface by setting the dhcp settings. Now every time when I do start the image with genymotion the dhcp settings are getting overridden as show in the screenshot.
So how can I persist the dhcp settings?
The Cause of the Problem
Genymotion is rewriting your network settings in VirtualBox because it has it's own way to handle network connection. That is due to the fact that Genymotion needs to make the android emulator think it has a cellular network or WiFi connection.
Defining Network Through Genymotion Settings
Because you said that Genymotion keeps resetting your VirtualBox's network configurations, I think it might have something to do with Genymotion's own network configuration.
In order to define your network setting in Genymotion, you need to do the following:
Open Genymotion => Settings => Network tab. You will get the following screen and in there you need to enable HTTP Proxy:
It is called a proxy, but it is supposed to work as kind of a "bridge" between your machine's DHCP and the emulator.
You might need to define the connection inside android system too, depending on the case.
If so, inside the emulator itself, go to: Settings => Wi-Fi => Long Click on WiredSSID => Modify network => Advanced options and modify the setting there too accordingly.
If that's not helping, you might need to change the specific setting of your emulator's virtual box:
Network Configuration via Virtualbox Settings
Genymotion uses two different kinds of network configurations in VirtualBox in order to operate.
An internal and technical network (defined in Network =>
Adapter 1 of VirtualBox settings) that helps Genymotion to display
the virtual device screen or forward events (clicks or widgets) to
the virtual device. This network configuration needs to remain untouched. Changing this may prevent Genymotion to run properly.
A network simulating access to your local network and to the Internet (defined in Network => Adapter 2 of VirtualBox settings). This network configuration is the one responsible for the emulator's internet connection.
So, you can configure Network => Adapter 2 of VirtualBox settings as desired, according to the following cases:
Use NAT, if you are using Genymotion on your local machine.
Use Bridged Adapter, if you need your virtual device to use an IP address of your local network (a DHCP server in your local network is required).
You will need to choose the Bridged Adapter option, in your case.
Make sure to change that setting in your specific VirtualBox device.

How to enable Genymotion emulator to use the WIFI internet the host is using

The app I am running on Genymotion emulator needs internet. The internet does not seem to work on the Genymotion emulator. I tried to confirm this by opening the browser, and this is what I got:
I am running Windows 7 on my laptop and using the Wifi internet. I opened Oracle VM Virtual box, navigated to Settings > Network, and the following two images show what I see there:
So how do I enable the emulator to use the internet from my computer?
Note: Please tell me in layman terms. I saw articles and questions talking in terms of IP addresses and other things which are strange for me.
EDIT 1:
goto settings in the device and turn on the device wifi, in the android OS. You haven't mentioned it in your post I'm just covering the basic solutions here.
Simply choose the Host-only Adapter for Adapter 1 and NAT for Adapter 2.
Make sure the cable-connected is selected(ticked).
Host-only can be used to create a network containing the host and a set of virtual machines, without the need for the host's physical network interface. Instead, a virtual network interface (similar to a loopback interface) is created on the host, providing connectivity among virtual machines and the host.
This works for me.
Hope it helps.
Try just turning on the WiFi in GenyMotion and selecting the WiredSSID.
I know this question been answered, but thought a picture would be easy to understand. Hope it helps.
No of the above solution worked for me, I fixed the issue by changing the ip address settings on the adapter by going to File >> Preferences >> Network in VirtualBox:
Adapter
IP: 192.168.217.2
Network Mask: 255.255.255.0
DHCP Server
Server Address: 192.168.217.100
Server Mask: 255.255.255.0
Lower Address Bound: 192.168.217.101
Upper Address Bound: 192.168.217.254
Go to settings >> Network in VirtualBox: adapter 1 >> advanced >> MAC address button generated new mac address.
I hope it solves the problem.
Go to your PC Ethernet or WIFI Settings and change the Adapter Preferred DNS Server to 8.8.8.8
In Genymotion,
Go to settings of your device and make sure adapter that you have selected is NAT(Default) not bridged or anything..
Now, make sure that your PC is connected to Internet...
It will work , most probably

Android emulator Internet connection

I am using win 7 64 bit OS, using Android 2.2 my emulator couldn't be connected to computer. I am using internet behind proxy server. I change the APN setting by filling proxy setting of my machine. But still I can't be connected to the internet Please any one who can help me? Thanks for your answers.
You can set the proxy in the emulator.
This link describes all the options https://developer.android.com/studio/run/emulator-networking.html.
One way is when you run the emulator from the command line add -http-proxy:
emulator.exe -avd YOUR_AVD_NAME_HERE -http-proxy http://<machineName>:<port>
or
emulator.exe -avd YOUR_AVD_NAME_HERE -http-proxy http://<username>:<password>#<machineName>:<port>
And consider if you computer has more than one network interface. Maybe your emulator is trying to use one that is not connect, its very common. The simplest solution is just to disable the ETHERNET interface if you are using WIFI interface. Other way is to change the priority of your interfaces in the operational system. In Windows 10 you can do this by:
Goto Control Panel > Network and Internet > Network Connections
Right click the desired connection (Higher Priority Connection)
Click Properties > Internet Protocol Version 4
Click Properties > Advanced
Uncheck 'Automatic Metric'
Enter 1 in 'Interface Metric'
Click OK
Repeat for the Lower Priority Connection, but this time put 20 into the 'Interface Metric'
You'll now use the higher priority connection as a default.

DNS server cannot be found

I created a simple examples and run it in emulator, every time where the emulator prepare to running it gives me a warning:
DNS server not found
and emulator starts normally. What does this mean and what this effect on my application? Why does android need a DNS server?
Do this:
Open Eclipse
Window>Preferences>Android>
Click Launch
I hope you see the Default emulator options
Then put the values that box -dns-server 8.8.8.8,8.8.4.4
If you are using a LAN connection to internet and you have a static DNS set there, the emulator might have a problem with that, if you are using wireless for example.
The Android emulator is using the DNS server to connect to internet so you can access different features from the internet within it.
Check your LAN configuration. If you are using wireless connection and you have LAN DNS server set, just remove it from LAN, and it should work.
I've had issues with DNS resolution on the emulator, which I am usually able to fix by killing and restarting the emulator.
windows->preferences->android->launch->
paste: to default emulator option as:
-dns-server 8.8.8.8,8.8.4.4

Android Emulator (qemu) does not allow certain tcp connections (RST,ACK as answer to SYN)

Although Internet browsing works in the emulator, my app who also runs in the emulator, is unable to connect to a server on the internet on port 5222 via TCP. I'm pretty sure that there is no firewall involved on my router or on my pc, as I can telnet to that ip:port from my pc.
Here is a screenshot of the packettrace taken on the emulator: http://i.stack.imgur.com/sIFFM.png
A packet-trace on the emulated device showed that every SYN packet to that particular port is answered with RST,ACK and the connection is closed by my app with a "connection error".
Why does the emulator block (?) these ports? How can I change it?
The Emulator runs on it's own network, so if you want to communicate through different ports you have to setup forwarding correctly for non-standard ports.
If you want to have external applications connecting to your application running in the emulator you will need to setup your forwarding so that the external application will connect to the port on your development machine and emulator will forward it connection to the 10.0.2.15 which is the emulators address.
See the dev guide for more info:
http://developer.android.com/guide/developing/tools/emulator.html#connecting
Got it. As http://developer.android.com/guide/developing/tools/emulator.html#proxy states, the proxy set in the environment variable http_proxy will be used for all TCP connections.
But my proxy is configured to allow only certain TCP ports.
unset $http_proxy
or use
emulator -http-proxy none
("none" is not a correct proxy, so it will give you an error message. But at least the environment variable is not processed)
PS:
If the -http-proxy command is not supplied, the emulator looks up the http_proxy environment variable and automatically uses any value matching the format described above.
Google, thats crazy. I've set the http_proxy environment variable because I wan't the http(s) traffic to go through that proxy. Not all TCP Connections.

Categories

Resources