Android emulator Internet connection - android

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.

Related

USB debugging on physical device within a virtual machine development environment

I have a development environment set up in a Hyper-V virtual machine (Windows 10). Using Visual Studio 2019 as my IDE with Xamarin (a monodroid project).
My physical device is unable to "passthrough" due to decisions made by the Hyper-V designers, from what I've read.
I have also tried to use workarounds, unfortunately, the device does not show up (even in Device Manager) in the Guest machine.
I was unable to see the device (within the IDE) initially, however, after some research and work, I've managed to get the device showing. I used this to "trick" adb running on the Guest to see the device (which is connected to my physical machine).
Host machine runs the script with IP 192.168.1.13 on port 6037 (adb daemon runs on 5037, which is default). Guest machine runs the script, with remotehost set to the Host IP, with the same port. I believe this configuration is fine, according to the documentation.
Unfortunately, even though I am able to deploy to my device, the debugger is unable to connect, and I receive Cannot start debugging: Cannot connect to 127.0.0.1:29300: No connection could be made because the target machine actively refused it 127.0.0.1:29301
Couldn't connect debugger. You can see more details in Xamarin Diagnostic output and the full exception on logs.
From what I have gathered, the debugger is trying to connect to localhost, and since the IDE is running within the Guest, the physical device will not be at localhost:29301. I assume if I could get the IDE to connect to 192.168.0.13:29301 (Host IP) instead, it would find the device, given that's where it is connected.
When I run adb devices, both the Host and Guest show the physical device, and after attempting to run the debugger, running adb forward --list, the forward rules are as such:
V4QBB18807150883 tcp:29300 tcp:29300
V4QBB18807150883 tcp:29301 tcp:29301
I can also see in Xamarin Diagnostics that setprop "debug.mono.extra" "debug=127.0.0.1:29302:29303,timeout=1585047190,loglevel=0,server=y" is executed. I assume manipulating that would give me some joy, but, I don't know how.
I'm not too familiar with adb and networking, so anyone with more experience in the matter could shed some light on my situation.
How can I get the debugger (within the Guest) to connect to my physical device?
PS: I've searched a lot before asking here. I know this exists: How can I connect to Android with ADB over TCP? and even after trying multiple answers on that page, I was unable to solve my problem.
After considerable amount of research, I came across this. Instead of searching for a way to set up adb port forwarding, I tried to see if there was a way to set up a USB passthrough via Hyper-V.
If using RDP is an option (directly connecting through "Hyper-V Manager" also works):
On host machine
Press Win+R type gpedit.msc and hit enter
Go to Computer configuration > Administrative templates > Windows Components > Remote Desktop Services > Remote Desktop Connection Client > RemoteFX USB Device Redirection
Select the only GPO there and Enable it and change the access rights to "Administrators and Users"
On VM:
Press Win+R type gpedit.msc and hit enter
Go to Computer configuration > Administrative templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Device and Resource Redirection
Select GPO "Do not allow supported Plug and Play device redirection" and disable it
Reboot both machines...
You may need to force update Group Policy, as per this comment:
I had to force update group policy (gpupdate) for it to take effect. Just shutting down and restarting both host and vm wasn't enough. Thanks
Eventually, after carrying out those steps (I ran gpupdate and restarted both machines), I had an extra option of listed devices, "Other supported RemoteFX USB devices", within that was my physical device. After checking the tick box, the VM detected the device without the need to port forward.
This can potentially cause security risks allowing a passthrough like this, however, my VM is not public and only accessible via my Host.
I would appreciate if someone in security could comment on the possible security risks just to inform myself and potential others that come across this post.
This is an old post but for anyone stumbling upon it, I found an alternative way to connect a physical device to a Hyper-V VM. I was able to get this working on a Hyper-V VM running Ubuntu 20.04. There was no way I could edit the group policy so instead I found a way to connect my VM to the same wifi as my device. Once connected, I could use Android Studio to pair it that way.
I followed the guidance here: https://superuser.com/questions/1403016/how-do-i-setup-a-working-wifi-internet-connection-on-windows-10-hyper-v
Open Hyper-V Manager
Click "Virtual Switch Manager"
Click "New virtual network switch"
Name: NAT, Connection type: "External network", Select the correct network adapter. Tick "Allow management operating system to share this network adapter.
Right click Ubuntu, select "Settings"
In Network Adapter, Virtual switch, select "NAT"
Go to "Control Panel > Network and Internet > Network Connections" in Windows 10
Right click the network adapter that is in use. For me, it is "Ethernet 2"
"Properties > Sharing", tick "Allow other network users to connect through this computer's Internet connection" and select "vEthernet (NAT)" in the drop down.
Tick "Allow other network users to control or disable the shared Internet connection", then OK.
Start Ubuntu virtual machine and test!
Once I followed those steps, Android Studio was able to pair with my device over the wifi.

Wi-fi not connecting to Android Studio emulators

My windows m/c's Wi-fi not connecting to Android Studio emulators. I have been using Emulators last one year or so, I have never faced this type of issue. Whenever I was starting Emulators, Wi-fi was getting connected immediately automatically. But last few day it wasn't happening. Wi-fi not getting connected in Emulators. I have tried so many things but it couldn't get solved.
Interestingly Wi-fi connecting in Genymotion android emulators.
Android studio setting
Settings/Appearence & Behaviour/System settings/HTTP Proxy
No Proxy Enabled.
Emulator setting
Try to update the version of Android Studio to the latest one and when creating a new emulator make sure that the emulator has GooglePlay service enabled,
as also shown down below:
I hope this will save your troubles.
After super struggle I found answer. For windows o/s go to
Control Panel\Network and Internet\Network Connections
Select your internet connected adapter
Right click--Properties
Check & Select IPv4(if already checked IPv4 than select so property will be activated)
Click properties
Check 2nd radio button-- Use the following DSN server addresses
Enter DNS address as 8.8.8.8 click Ok.
To not to confuse, IPv4 =Internet Protocol Version 4(TCP/IPv4) option
That's finish..Enjoy

Genymotion emulator no internet connection

I am trying to connect my genymotion emulator to internet and got this message:
emulator network configuration:
On Mac Os I solved No Internet Connection Problem on Genymotion emulator using next steps:
Go to Android Settings -> System -> Developer Options -> Turn On Developer Options
In Settings go to Network & Internet -> Mobile Network -> Turn Off Data Roaming
In Settings go to Network & Internet -> Data usage -> Turn Off Mobile Data
In Settings go to Network & Internet -> Wi-Fi -> Turn On Wi-Fi
And Internet Connection should be established. Also restarting the emulator may be required.
I didn't change anything in VirtualBox:
Best network configuration for an optimal use of Genymotion
To run properly, Genymotion uses two different network configurations:
An internal and technical network (Network > Adapter 1 of VirtualBox settings)
This network is used for example to display the virtual device screen or forward events (clicks or widgets) to the virtual device.
Changing this network configuration may prevent Genymotion to run properly.
If you get the message Unable to connect to the virtual device, please refer to When I start a virtual device, why does the window remain black?.
A network simulating access to your local network and to the Internet (Network > Adapter 2 of VirtualBox settings)
You can configure it as desired, but be aware that an error in this configuration may prevent Genymotion to access the local network and the Internet.
We recommend that you use the following configuration:
NAT, if you are using Genymotion on your local machine.
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).
Currently, this network is regarded as the Wi-Fi connection of your virtual device.
Reference:
https://www.genymotion.com/#!/support?chapter=network-configuration#faq
First of, check your VirtualBox Host-Only Network #2 in: Control Panel\Network and Internet\Network Connections, has the correct properties as follows:
Navigate to Control Panel\Network and Internet\Network Connections and Right click the Connection: VirtualBox Host-Only Network #2
Select Properties
From the popup, activate the VirtualBox NDIS6 Bridged Networking Driver by checking/ticking the check-box and click OK
Lastly, navigate to Oracle VM Box\Google Nexus 7 4.4.4 ...\Settings\Network\Adapter 2 and enable the Network Adapter 2.
Hope this helps resolve your issue.
PS.
If you are connected via wireless and you have followed the above, do try un-checking the cable connected check box under Adapter 2 as shown in the image below.
Try this:
Just turn Wifi on and select WiredSSID network.
1) Open the Oracle VM VirtualBox manager
2) Settings->Network
3) Select the Adapter 2 (Adapter 1 is used primary by Genymotion and cannot change)
4) Select the NAT
5) Restart the VM and Genymotion
Otherwise:
Try on the virtual device > go into Settings > Wi-Fi > Select the IP automatically > After that just click on Done > and now... connected to the internet.
try to uninstall your android virtual device that cannot access internet in genymotion, and re-install a new virtual device. I tried and fixed.
The reason I guess is I installed genymotion and add virtual device before install the virtualbox.
Update Virtualbox and clear-cache work in my case
update virtualbox
genny motion - preference - misc - clear-cache -> restart emulator
I faced the same issue and followed all above instructions, but not worked.
Open Oracle VM Virtual box
Select the custom phone ->right click->settings->General->Basic
Change the type to your current OS (My case Mac OS X)
Choose Version of the Mac OS (64 bit)
Only this solved my problem.
My problem was that I changed the IP of my machine, and I already had the vitual device configured. To solve, I clicked on wifi on the virtual device, clicked on the WiredSSID network and chose the "forget" option.
Open the Oracle VM VirtualBox manager, Settings->Network, Select the Adapter 2 because Adapter 1 is used primary by Genymotion and that's why each time you change it and restart the vm it reset itself to old settings, using Bridged Adapter and select the working network card. if you are behind proxy, please use NAT
In my Mac, genymotion device's WiFi was off. So I solve this issue only by turning on the WiFi. and internet starts back to work
Try to ping your VM ip :
ping 192.168..
it is possible that a firewall blocks the connection. try to stop it : go to process and search for firewall and stop it.
I had similar issue:
I had a LAN cable internet connection to my laptop. (No wifi )
In Genymotion, I opened wifi and there was a wifi network available , just connected to that network. Then it worked.
(But actually I haven't turned my modem wifi, I think its some kind of virtual wifi)
In your Computer go to Control Panel > All Control Panel Items > Network Connections then change the Network Adapter Preferred DNS Server to 8.8.8.8 which is Google Server
Below steps helped me:
(i) Enabled network from sidebar
(ii) Enabled Developer Options
Late but I had a similar issue when running Genymotion(3.2.1) on Windows10
I had the Windows "Virtual Machine Platform" on as I was using WSL2
I disabled it,restarted my system and Genymotion got connected to internet.
Hope someone finds this useful.
What worked was pulling down the notification bar and clicking the Wi-Fi icon to turn it off and then back on again 😂

No network in VirtualBox (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

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

Categories

Resources