Simulate network problems within an android emulator - android

I would like to simulate some network problems with the emulator. I know that pressing f8 I can disable the network but, as a result, I lost the connection with eclipse, the adb and the debug session!
Furthermore, I can not test the case where a server may not work well while the network is ok, or other similar network problems.

Install GenyMotion
Setup a VM of a tablet
Use this via Eclipse
Then in the VM
Settings
WiFi OFF
Works a dream , just tried it
Phil

You can use telnet to get access to the Android Console within the emulator, and from there you can affect speed and latency of the emulated network connection.

Related

Android emulator keeps losing internet connection after a few minutes of running

When I start up the android emulator, I have internet working on the entire device (all apps have internet access, my own included). Unfortunately within 5 minutes of running, the device looses it's ability to connect to the internet.
Example Usage
1.Boot Device (boot completed at 09:00)
2.Open Firefox
3.Start using the internet
- Internet works fine. I visit 4 different sited in this time.
4.Internet becomes very slow (first noticed at 09:03)
5.First error message happens at 9:05
From here on out I cannot connect to the internet until I reboot and start the process all over again.
I have tried creating entirely new system images to make sure it is not a configuration problem with one particular emulator setup, but that did not help.
Though many similar questions have been asked before, I was unable to find a solution to this problem. Any insignt you might have is appreciated. If there is anywhere I can go for more detailed logs, please point that out too.
Your issue is with DNS
Are you using wireless? Is your LAN adapter connected? You may want to disable it so adb doesn't try to use it for DNS
How to connect android emulator to the internet
Otherwise, try explicitly passing a DNS server to the avd at startup:
emulator.exe -avd INSERT_AVD_NAME_HERE -dns-server 8.8.8.8
No internet access on Android Emulator, Shared Internet Connection

Enable/Disable Data Enable mechanisam in Genymotion Emulator

I am using Genymotion Emulator with Nexus s and 4.2.2.
Previously i used regular AVD that we can create using Eclipse provided by ANDROID SDK.
In regular AVD we can enable/disable data packet access to internet by using
Settings->Wireless&Networks->Data Enabled
Or by pressing F8 key but i am unable to found it in Genymotion emulator.
Where i can find it?
You cannot do that on Genymotion.
If you want to test what your application will do without internet access, you can unplug your ethernet cable or switch off your Wi-Fi.
It's not the same but could still help to test your app.
I hade this problem.
If you disable the internet and try to debug your app, the app will not be able to connect to vs code debug server.
This what you should do.
1- in your emulator, click Debug/settings and change the ip:port to the following localhost:your port eg 5555
2- disable the wifi and your app will start without internet but still able to connect to vs code

Cannot ping/communicate with Android devices on the same network

I have a nexus 7 running CM10.1 . For some reason i cannot reach it from my laptop on the same wifi network. I cannot ping in either direction. In the past i have been only able to ping one way.
Just tried out on my stock htc sensation and havent the same issue. Also the nexus and htc cant reach each other either.
I have had similar problems with other android devices, in the past i was developing an app and i could not establish a socket connection from the android device to my computer. Once i was able to successfully ping the laptop form my device everything worked.
This isn't persisant, in the past i fiddled around they eventually talked but there was no consistant solution at the time, i never got to the root cause.
I have obvsered this on 2 different wifi networks
Not sure what is happening here my understanding of networks isn't this deep.
My first guess (assuming you're using the right IP, no firewall conflicts etc.):
Check the WiFi Sleep Policy in the WiFi-Settings of your device. You should set it to Never and then try to ping it once more.
That's the way you'll find the option on your android device:
Settings -> Wireless & Network Setting -> Wifi Settings -> Press Menu button -> Advanced -> WiFi Sleep Policy

Android emulator Wi-Fi

Is it possible to connect the emulator to Wi-fi? Since am not using eclipse or any IDE... Am trying to connect a stand alone emulator to Wi-fi
Currently, while you can use your computer's Internet connection in the emulator, it's not reliable to use it for simulating Wi-Fi. The WifiManager gets confused when you switch/want to test your connectivity state.
Even in Android 1.5, there were some problems with it (Issue 2571 - android), and while you can use your Internet for simulating HTTP connections and downloading data, finer control over Wi-Fi connectivity should better be done with a device.
If you mean that the emulator should connect to the internet via your PC/MAC then it works without any changes.
I am able to browser the internet via the browser in the emulator i.e. the emulator has internet connectivity.

How can I get my android emulator use my computer's VPN interface?

My company requires VPN to connect to our dev systems and for the first time I'm trying to work on an android app from home. Turns out the emulator doesn't want to use the VPN interface so even though I have connectivity to our dev systems on my VPN-connected laptop the emulator that's running on it does not.
I have thought of 3 solutions to this:
run a VPN client on the emulator, but I was hoping for a simpler solution than that
setting up a proxy server on my local machine
forwarding a port on my local machine
2 and 3 can probably work, but I'd still like to know if there is an easy way to get the emulator to use the VPN interface without a workaround.
I'm running OS X 10.7 and I've already tried adjusting the interface priority order with network>>set service order.
I suppose I can dust off the old dell and try it there, but I would expect the same results.
First start your vpn connection and then restart the emulator, now the emulator should use the host vpn connection.
it's mostly because of the DNS issue, according to the android doc:
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.
I encountered this issue and tried something on dns settings but I could not solve it. As #machado said in the comment section below you should boot the emulator via "Cold Boot Now" option. I hope this helps.
What I do on my mac is just make sure 'send all traffic over vpn' is checked.
You'll find this setting after you click advanced while having your vpn connection selected in network preferences.
Works well for my situation, but may not depending on the type of VPN you're connecting to.
I had the same issue and solved it by connecting to cisco vpn after the android emulator has started and connected to the internet.
Works for me in windows 7
I setup a vpn connection on Windows. Then I started the emulator. The emulator and everything on my pc started to use that vpn connection.

Categories

Resources