Android emulator not able to access the internet - android

I know that similar questions have been asked before, but my problem is new only after installing Android Studio 2.3, the latest version in March 2017. I have several years experience developing Android applications, and I have never encountered this problem before. After upgrading to version 2.3 of Android Studio, my emulator is no longer able to access the internet. I even uninstalled/reinstalled Android Studio 2.3 from scratch and created a new emulator, and I am still getting the same error. This is not an app problem. I can't even access the internet from Chrome, and I wasn't having this problem last week. The message that I get says that the server DNS address could not be found -- DNS_PROBE_FINISHED_BAD_CONFIG. The only thing that has changed on my computer in the last week is the new version of Android plus possibly updates to Windows 10. And yes, my computer has access to the internet. Below is an image of my emulator when I try to use Chrome to search for "Google".

1st try "Cold booting" the emulator as suggested here.
If cold booting doesn't work, try changing the DNS address of your network to 8.8.8.8 (Google's DNS) or another of your preference:
MacOSX:
Open "System Preferences"
Click on "Network"
Select the network which your computer is connected and click on "Advanced"
Select "DNS", Select the "+" button, type "8.8.8.8" (Google's DNS) or if you prefer OpenDNS, "208.67.222.222"
Select "Ok" and "Apply"
Windows & Linux:
https://developers.google.com/speed/public-dns/docs/using
After that close the emulator and start it again.

After trying many of these solutions, I was going to just delete my current AVD and make it again, but when I clicked the down arrow on the AVD, I noticed "Cold Boot Now".
On a whim I tried that. Lo and behold my emulator has internet connectivity again!
Command-line approach
In case you start Emulator through command, pass -no-snapshot-load option, like:
%ANDROID_HOME%/emulator/emulator.exe -netdelay none -netspeed full -no-snapshot-load -avd Pixel_2_API_28
Or for MacOSX:
$ANDROID_HOME/emulator/emulator -netdelay none -netspeed full -no-snapshot-load -avd Pixel_2_API_28
Note that you may need to change -avd Pixel_2_API_28 part (with your own Virtual-Device name).
Also, most tools use ANDROID_HOME environment-variable name, hence define that (if not already), but nowadays ANDROID_ROOT is yet another naming-option.
Decision (edit)
Ok, for those saying why not just wipe data and restart.
Do you reformat your PC every time you restart it? Wiping data on the emulator is just like doing a factory reset to a phone or reformatting your hard drive on your PC and reinstalling your OS. It is unnecessary unless the data is totally corrupt.
When you shut off the emulator and restart it, it is like putting your PC in hibernate or sleep mode. Memory is not wiped, it is saved.
Doing a cold boot is the same as rebooting your phone or rebooting your PC. It resets memory and lets things reload. This allows the network emulation to start with clean memory and connect properly.
So, don't wipe your data. Just cold boot. If it still doesn't work, then wipe, but save that as a last resort.

I found a temporary solution on an old Stack Overflow thread at Upgraded to SDK 2.3 - now no emulators have connectivity. Note that this thread talks about Android SDK 2.3, not Android Studio 2.3. The problem seems to be that the emulator can't find the DNS my computer is currently using, and the temporary workaround is to start the emulator from the command line and specify the DNS server. Whatever problem occurred back then must have reappeared in the latest version of Android Studio.
The temporary solution outlined below fixes the problem with the emulator accessing the internet. However, it does not fix the problem that occurs when trying to run Android Device Monitor. Doing so will still make the emulator go offline as described above.
Note that there are two files named "emulator.exe" in the sdk -- one under sdk\tools and another under sdk\emulator. Either might work below, but I use the one under sdk\emulator.
The first step is to find where the SDK is located. Assuming a user name of "jdoe" and a default installation of Android Studio on Windows, the SDK is most likely in
C:\Users\jdoe\AppData\Local\Android\sdk
The second step is to determine the name of the AVD (emulator) that you want to run. The command
C:\Users\jdoe\AppData\Local\Android\sdk\emulator\emulator.exe -list-avds
will show the names of your AVDs. On my computer, it shows only one, Nexus_5X_API_25.
To start the emulator from the command line with a specified DNS server, use something like the following:
C:\Users\jdoe\AppData\Local\Android\sdk\emulator\emulator.exe -avd Nexus_5X_API_25 -dns-server 8.8.8.8
In this case, 8.8.8.8 is a Google public domain name server.
The above commands can be shortened if you create appropriate environment variables and edit your PATH environment variable, but I recommend caution when doing so.

[UPDATE 2022] for Mac Users
For NOT Apple Silicon users
System Preferences
Network
WiFi > Select Advanced
From Advanced Choose DNS tab
Add DNS Server 8.8.8.8
Emulator must be restarted after DNS Server has been added (Thanks to #kapusch)
For Apple Silicon users
as per #bourdier-jonathan
You can fix the Silicon issue here:
Emulator appearing offline on M1 Mac after the last update of arm64-v8a
By replacing the AVD system images you have downloaded with the r02 images. Because It appears r03, r04, and r05 all don't work on m1

Updating my WIFI adapter to resolve DNS on 8.8.8.8 solved the issue for me. It started to happen after an Apple update which messed up the DNS address.

Simply open the AVD Manager and wipe the data of that emulator works for me.

Open Android emulator and go to the Extended Controls. Then go to the setting => proxy(Tab), uncheck "Use Android studio HTTP proxy setting" and click "Apply".

macOS: long Story short.. make sure your DNS settings 8.8.8.8 is the first in line, wipe your data and do a cold boot.

Reminder: the Android Emulator internet connection does not work if you turn on a VPN system on you computer.

I experienced this same issue after upgrade. Upon opening the Chrome browser in the emulator, google.com could no longer be reached.
I found a post on SO that suggested the problem was with the emulator trying to use a disconnected network adapter. For me the problem was occurring when I was connected to a LAN. Disabling the wireless LAN adapter fixed the issue.
To disable the adapter:
Navigate to Network connections
Find the adapter
Right click and choose disable

I've resolved wiping data from AVD Manager

This happend to me when the emulator froze and I had to kill the process. The signal icon always showed the small "x" as in the screenshot and no internet connection was successful.
The only thing that helped was uninstalling and reinstalling the emulator (not the AVD images)
In Android Studio:
Tools-> Android -> SDK Manager
Uncheck "Android Emulator" and let it uninstall then check again and let it install again.

I am also facing the same problem, but I am trying to solve the problem using various posts. Today I discovered this problem. Your computer configuration is most likely the problemm, not Android Studio and the Android Emulator.
The problem is coming from your Network setup. Just set the Primary DNS Server to 8.8.8.8, which will solve the problem.

I got a simple and permanent solution for this issue in windows.
Go to network and internet option->
click on Etherenet or wifi(for which you are connected) option ->
Click on change adapter option ->
Right click on the network for which you have connected.
A dialog box will be opened and just click on Internet protocal version (TCP/IPv4) option.
Another dialog box will be opened and there just neglect the first set about the IP address (Keep as it is set) and click radio button of Use the following DNS server addresses: and enter as 8.8.8.8 in Preferred DNS server: and 8.8.4.4 in Alternate DNS server:
Now you can open your emulator whenever and you will get internet in the android emulators.

For me the problem was caused when I took my laptop home without restarting the emulator. From what I have read, when the emulator starts up it reads your PC's DNS settings and uses them. When I was on my home network, my work DNS settings were failing.
So yeah. Just restarting the emulator solved my problem.

This was a problem for me last time the emulator updated itself and back then disabling other network adapters fixed it. Now it's cropped up again but the only adapter that is enabled is a single wifi one so I have nothing to disable.
The issue only reappeared after I updated via a prompt the emulator tools to 26.1.1. I uninstalled and reinstalled the emulator via the SDK Tools update tab and thankfully the only option when installing again right now is to install 26.0.3 (which seems to be working okay).
Moral of the story is to be very wary of emulator updates.

I faced this problem after i kept my emulator ON while going from my home to a cafe. "Cold Boot Now" fixed the issue.

After 10 days of trouble, I just deleted everything from C:\Android\.android\ and deleted all created AVDs. Now internet seems to work fine.

closing the emulator and reopening worked for me
OS
WINDOWS 10

Just goto AVD manager and Cold Boot Now worked for me

I can make it work after turn off and turn on the wifi on android config

Please go through the below link.
https://developer.android.com/studio/run/emulator-networking
Emulator open, click More ..., and then click Settings and Proxy. From here, you can define your own HTTP proxy settings.
Enter the hostname by following
Run > cmd > hostname
Finally, check the internet access inside the emulator by browsing in chrome or google.
Note: Often wipe data will clear the issue. Please follow all steps

I am on android studio 3.1 and it happened.
Solved it by restarting the adb server
$ adb kill-server
$ adb start-server
Hope it helps. Thank you

There was a problem for me too, by disabling the proxy in Android Studio settings, and run the emulator with "Cold Boot Now", the problem was resolved.

Solution for MacOS that does not use a custom DNS for your whole machine
Step 1
Locate the emulator executable Android Studio is using inside the Android SDK and rename it to emulator-original.
Mine is located /usr/local/share/android-sdk/emulator/emulator but it might vary based on individual setups.
Step 2
Add a new file called emulator in the place of the original file containing the following command (or using your DNS server of choice).
#!/bin/bash
$0-original "$#" -dns-server 8.8.8.8
Step 3
Make the new emulator file executable.
chmod +x emulator
Step 4
Restart the emulator using Android Studio.

if android browser can access internet
you can run emulator from terminal
by this command
go to SDK path then
$ /tools/emulator -avd
Nexus_5X_API_23 -netdelay none -netspeed full
it solve your internet problem...

I was having the same issue and i resolved with below steps:-
Go to emulator setting and then go to
setting->Proxy->Either configure it Manually or use Tick use Android Studio HTTP proxy simulator.
please vote, if this works for you

Try these steps once, they worked for me:
Disconnect your PC from the internet
Close the emulator while you are still disconnected
Again connect to the internet
Finally start your emulator again

Just recreating the emulator with another target API worked for me

Maybe you set a proxy for Android Studio and the proxy does not work. Try without proxy.

Related

Android Emulator keep showing allow USB debugging prompt

I just installed Android Studio Bumblebee (2021.1.1 Patch 2)
But when I try to run my emulator, I got allow USB debugging prompt that always showed up even after I press allow, check the always allow option, or even cancel it.
I already tried to restart my adb server and remove and create a new emulator, wipe the data and try to cold boot it, but the issue persists.
Does anyone know what is the root cause of this issue and how to solve it?
I can still develop using real device but I do want to know if this issue able to be resolved.
Emulator: Google Pixel 3 API 30
If the "Allow USB debugging" message is shown again and again then this is usually a problem of the host, not of the Android device.
You should reset the Android ADB authentication key by deleting it and then restarting ADB. A new authentication key (pair) will be generated which will hopefully work.
To do so delete the files adbkey and adbkey.pub in the folder ~/.android/.
Then execute adb kill-server and finally restart adb by executing adb start-server.
Note that this will reset USB ADB authorization of all devices you had connected to that PC/user account.
I had the same issue and and manage to fix it by turning off and back on usb debugging in emulator developer options. Still don't know what caused the issue in the first place.
I able to resolve this issue by creating new AVD with X86_64 system image.

Cannot Run App On Genymotion Emulator From Android Studio

My OS is Windows 7 Pro, and I installed Android Studio 2.1, which is the latest version at the moment, and I followed the instruction from this video tutoril to install and setup Genymotion, I did each step exactly as the video shows, but in the end I cannot run my app on the virtual device created in Genymotion(but in the video, it works fine), what I got is:
As shown in the screenshot, the emulator on the left is started from the Geny plugin in AS, and the right dialog is what I got after I click Run button, it seems that the virtual device is not recognized by AS.
The Event Log is:
11:18:01 PM error: could not install smartsocket listener: cannot
bind to 127.0.0.1:5037: Only one usage of each socket address
(protocol/network address/port) is normally permitted. (10048)
11:18:02 PM could not read ok from ADB Server 11:18:02 PM * failed to
start daemon * 11:18:02 PM error: cannot connect to daemon 11:18:02 PM
'C:\Users\Vincent\AppData\Local\Android\Sdk\platform-tools\adb.exe,start-server'
failed -- run manually if necessary
What I have tried so far:
Firstly, I found this post: Android Studio Unable to Find Genymotion Device, which gives a link of a discussion in google forum: https://groups.google.com/forum/#!topic/genymotion-users/ov5ANqGf3DI.
From the discussion, one named Jordan said that two things need to be done: "bridged adapter" and "port forwarding". But in the setting panel of VirtualBox on my PC, what I found is:
If I set Adapter2 as bridged adapter, the 'Port Forwarding' button will be disabled. So I cannot do both things at the same time. I tried bridged adapter first, it didn't work, and then I set it back to NAT as default, added the port forwarding rule, ran the adb command as explained in that post.
BTW, the approach they told to find the ip address didnt work for me, I could not install play store into that virtual device, so I figured out the virtual device's ip address from VirtualBox.
Anyway, neither of them works so far.
Secondly, I tried the approach in this blog: http://scrumsofanarchy.com/adb-over-wi-fi-with-genymotion-android-emulator/, and ended up with nothing, coz basically I cannot install any app into the virtual device.
Thirdly, I tried the approach in this post as well: android studio - emulator doesn't work and genymotion doesn't get recognized. My Genymotion is using the SDK installed by AS now, but that doesnt fix the issue.
I am running out of options now, any help is appreciated, thanks!
Just install GPU Debugging Tools 3.1 in Android SDK Mangaer ;-)

How to resolve "Warning: debug info can be unavailable. Please close other application using ADB: Restart ADB integration and try again"

I am having a slight issue when trying to debug and android app via usb to external device. I keep getting the error "Warning: debug info can be unavailable. Please close other application using ADB: Monitor, DDMS, Eclipse
Restart ADB integration and try again
Waiting for process:"
I have tried stopping adb.exe in task manager , closing android studio and restarting , taking out the cable and putting it back and going to tools => android uncheck adb intergration then recheck it . All to no avail
This is a problem of ADB connections as sometimes ADB cache a dead connection on your real/virtual device and due to which the port is busy and u cannot connect to it.
The simplest solution to this is RESTART your ANDROID phone that's it.
What worked for me was to disable and re-enable USB debugging on the device.
Following steps resolved this issue to me:
Disconnect the device.
Restart android studio.
Run the project.
Simply go to your Android phone developer settings, disable USB debugging, delete all authorizations for USB debugging and turn the debugging on again.
First make sure you close any application use ADB , DDMS
like if you open Eclipse with android studio
Second restart your ADB from terminal
adb kill-server
adb start-server
The issue occurs when I open the Android Studio and IDEA together.
Restart the Android Studio does NOT fix the issue
Re-plugin the cable either does NOT fix the issue
Restart the Mac either does NOT fix the issue
Restart the ADB from terminal FIX the issue
adb kill-server
adb start-server
In this way, you do not need to close the IDEA.
Updated: 2022-09-19
Restart the Android Studio does NOT fix the issue
Invalidate and Restart the Android Studio does NOT fix the issue
Re-plugin the cable either does NOT fix the issue
Restart the Mac either does NOT fix the issue
Restart the ADB from terminal either does NOT fix the issue
Restart the Android device fix the issue.
This problem sometimes occur when Android Studio is opened with another IntelliJ Editor. Just close the other IntelliJ Editor.
Open USB preferences in your device. Like the image below.
Click another option. (eg:File Transfer)
Click the no data transfer.
If it doesn't work,please try again.
The operations on the android devices are similar.
this may happen when you created two instances of android studio, or else you are using same device in multiple ADB programs, so simply disconnect you device and then open your desired android studio instance and then connect again. now it will work fine.
i also use same method and every time it works.
IntelliJ IDEA (Ultimate, probably also Community) comes with Android plugin. If IntelliJ is started and any project is open and has been compiled (even without any Android code-base) then IntelliJ (apparently) steals the adb-connection from Android Studio. Either close IntelliJ or disable the Android plugin in IntelliJ.
If IntelliJ is open with android plugin, rebooting phone, killing adb etc. are only sporadic and short-time fixes of the problem as IntelliJ steals the adb connection again.
I resolved this issue by changing the Use USB for settings
Go to setting select transfer settings in my case MIDI was selected.
Go to Airplane mode ON and OFF , After that everything back to normal.
In my case, I had my device connected both via WiFi (with adb tcpip) and USB cable. Disconnecting the USB cable solved the issue.
Quite awkward issue, I think none of the solutions mentioned above worked for me.
Ultimately, I had to invalidate caches and restart.
File -> Invalidate caches... -> Select both options -> Invalidate and restart
For me was Eclipse using DDMS and conflicting with Android Studio, I wasn't using, so I just uninstall it.
If is your case, go to Eclipse > Help > About Eclipse IDE > Installation Details > Select DDMS and Uninstall..
At times ADB caches a dead connection on device(real / virtual) due to which the port is busy and it is unable to establish a connection.
You can try different ways:
You can kill and restart the server:
adb kill-server
adb start-server
2). Try disconnecting the device(phone) and reconnecting it.
3). Restart your device (phone).
Slightly different answer, but I'm including it for completeness.
For me Android Studio had frozen as well with the spinning beach ball of death.
I rebooted the emulator (by having it emulate a power-off/restart cycle)
Killed Android Studio (on a Mac by using ⌘⌥esc)
Restarted Android Studio.
After that everything was back to normal.
if you open two Android Studio at the same time (android studio preview),Will be like this
A possible temporary work around that may work prove useful for progress sake when intending to debug is to run the app in android studio , then immediately click on run => attach to debugger

Eclipse IDE cannot connect to Mobile Device

I known there is lots of answers about this question, but still my mobile device not connected to eclipse IDE.
The following is what I already did:
1. restart adb or type command in cmd "adb kill-server/adb restart-server", eclipse find nothing in the devices.
2. execute netstat -aon|findstr "5037", finding there is only one process "adb" occupy the port
3. check the phone driver in device management, finding the phone is install correctly.
4. execute "adb devices":
List of devices attach
1f06cbba device
I thought may it's my phone's problem, so i remove it, and create a virtual device avd, the eclipse still don't work.
My Operating System is Windows 7 and Eclipse IDE Kepler.
can any body help me to successful run my first android helloworld?
Thanks a lot!!
additional explanation
debug mode is in phone is ON
adb is in the variable %path%(maybe some should answered)
try the latest adt-bunble in adroid website, it still don't work.
Try turning "developer options" on in your device. (Option you haven't tried).
To access these settings, open the Developer options in the system Settings. On Android 4.2 and higher, the Developer options screen is hidden by default. To make it available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options.
Have you added adb in your class path variables? If not , you should append the class path with following paths :
path-to-sdk/android-sdk/platform-tools
path-to-sdk/android-sdk/tools
Try re-installing ADT Plugin. Worked for me last time.
Install your current mobile Adb USB driver and update Google USB driver
Check the MTP/PTP mode for your device:
http://lh3.ggpht.com/-8UMNs7Vg_dY/UVC6_6PnbDI/AAAAAAAAAIg/NjKOvAp9cDs/02-select-camera-ptp-mode_thumb%25255B1%25255D.png%3Fimgmax%3D800
In some devices you can find this under Settings->Storage->Menu Options(three vertical bullet squares).
When you say->the phone debug mode is open, i assume your developer options usb debugging is already enabled

Constantly getting ...DeviceMonitor] Failed to start monitoring

I find that after running or debugging my application a few times using eclipse, that I get the above output in my console (in red) and I get no feedback from Dalvik as to the connection status to my phone is going. My application will still debug etc. I just get nothing useful in my Console.
Any ideas how to fix this? It appears intermittent. It starts doing it after a few minutes, continues to do it for quite a while and occasionally goes away again. This has happened on my last laptop and now on my new laptop with a completely fresh install etc.
I'm on Windows 7 64 bit; but maybe 2 or 3 times during the day I get this same error. I tried the reboot thing, which sometimes worked, sometimes didn't.
I have found the fix to be:
Close Eclipse
Unplug USB
Open task manager and find the "adb.exe *32" and End Task
Open Eclipse (not done yet)
"Clean All" (not just project)
Then build the project (for me, just building the project works)
Plug USB back in and there ya go!
Always works for me. If anyone knows of an update to something I can download to avoid doing this all the time, I'd love to know!
I had the same problem -
Try to use a different USB port.
From my experience, the USB connections on the PC front are not recommended.
Year almost 2018 I just had same problem which doubled my gray hairs. It turned out my test phone Samsung Galaxy S6 does not like the USB ports on my Apple Thunderbolt Display. I just plugged the USB cable directly to my Mac Pro and it worked right away. Funny thing is my Google Pixel Phone never complains about the USB port on Thunderbolt.
To keep the error message from showing up I did the following on Eclipse 3.7:
Window->Preferences
On the left side tree select Android->DDMS
In the DDMS settings window choose logging level "Assert"
Click "Apply"
You may have to kill the deamon and restart it. Following are the steps;
open a command prompt and locate the SDK's platform tools folder. E.g.:- cd c:\android-sdk-windows\platform-tools
then execute "adb kill-server" command. You will see the disconnected icon in run configuration panel is now cleared.
then again execute "adb start-server" command.
Then try running the device, if it doesn't work try restarting the eclipse.
restart your dev machine, worked for me :)
I was using a USB 3.0 port too and a device Xoom with ics 4.0.
To solve my problem, I needed to restart my Windows, because in the DDMS my device was showed twice.
After the restart, I needed to change the USB port to a 2.0 USB port and it work for me.
problem causes bay USB bug
1- save your work
2- Close Eclipse
3- restart your computer
4- Open Eclipse and enjoy ^^
it works for me
good luck

Categories

Resources