Failed to start Emulator console for 5554 - android

I'm trying execute my application, but it occurs the following problem:
Failed to start Emulator console for 5554
I've already done:
Clean and Build Project and restart

Check:
if you have downloaded all of the emulator files from the SDK Manager for the version you're trying to use.
if you have enough RAM left to use for the emulator (remember that you define it in the device config)
if there's not another emulator already running.
Another way to know what's the problem is to check the LogCat, it provides very useful information about errors and all the stuff running, if you can't figure the problem reading it, try to ask a question with the error message FROM the LogCat, not only the one from the windows in your screen.

I had the same problem.
Finally I launched the emulator in command line. use "sudo ./emulator #(your device name)", and it can work properly with port 5554.

Related

Why is "adb install (my APK)" triggering "can't find service: package"?

I am starting up an android virtual device, but I am getting:
Starting emulator for AVD 'avd.1'
pulseaudio: pa_context_connect() failed
pulseaudio: Reason: Connection refused
pulseaudio: Failed to initialize PA contextaudio: Could not init `pa' audio driver
emulator: Listening for console connections on port: 5558
emulator: Serial number of this emulator (for ADB): emulator-5558
The emulator is coming up but I see no icons on it so I'm wondering if the errors listed above are "showstoppers"? Then when I try adb install bin/my.apk I get the error Can't find service: package. So it seems adb is not communicating with the AVD correctly. However, adb devices does show emulator-5558 listed above. Any advice would be really helpful.
You have essentially answered your own question while asking it. The root of the problem is that the emulator is not setup properly (evidenced by the system UI not loading). When Android can't boot properly, it is likely to fail to start some system services (in this case, the package service).
The solution is to recreate the emulator, possibly with a different system image (in case the one you have been using is corrupt). If you are using an official image, try switching API levels, or switch from a GMS-enabled emulator image to a non-GMS image (or vice-versa).
It also happened to me after closing the emulator while debugging. Yes, not the best idea...
The solution for me was:
Click on Tools > AVD-Manager.
Click on the arrow to bottom on the right of the new window from your (virtual) device.
Click on "Cold Boot Now".
Don't forget to enable usb debug mode and in developer option to consent data file transfer, for me it solved this issue, hope this help
You can also get this fault when delpoying to physical devices.
The solution is to restart the adb server, using:
adb kill-server

Android emulator not able to access the internet

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.

could not access the package manager. is the system running while installing android application

While installing the android application in the emulator I am getting the following error.
Please help me to resolve this error.
Error message:
emulator.exe -avd avd_name
adb wait-for-device
adb install path-to.apk
could not access the package manager. is the system running while installing android application....
You need to wait for the emulator to full start - takes a few minutes. Once it is fully started (UI on the emulator will change), it should work.
You will need to restart the app after the emulator is running and choose the running emulator when prompted.
As other have said, this error occurs because the emulator is still in the process of launching. An attempt to access the package manager, for the device, at this time causes an error.
It's just a simple timing issue. Here are the steps to avoid this error:
Wait until the emulator 'lock screen' is showing.
Run the 'app' again (^R in most IDE's).
Choose the running device (Should be the same emulator).
App should install without error.
In my case it was just that the emulator took 9 minutes to start. Wait until you see the lock icon on the emulator LCD. Or use actual tablet or phone.
Facing Same issues following Link helped solving the problem. The above solutions were not helpful for me.
deployment-failed-could-not-access-the-package-manager-is-the-system-running
By restarting server using CMD application was back to work. Open cmd (Run as administrator), open this
cd C:\Program Files (x86)\Android\android-sdk\platform-tools
(this path must specify your android-sdk installation folder )
Now, first write,
adb kill-server and then adb start-server.
Kill the process/server and restart it.! It worked.
You can avoid the error by setting default device before launching application. Launch the AVD before starting the app.
Once you see this error, wait for emulator to show lock screen. And then relaunch the app in your IDE and check the emulator again. It works for me always.
In Android studio, you can relaunch by clicking the green play button or ctrl + r.
If this error is gotten when using a rooted device's su prompt and not from emulator, disable SELinux first
setenforce 0
You may need to switch to shell user first for some pm operations
su shell
then re-run your pm command.
Same applies to am commands unavailable from su prompt.
The solution for me was to restart the IDE. I suspect that a slow emulator was hiding from view, blocking installation on my device.
Check your project build is in Debug mode not Release, I had some problem for debugging always I forget to change Release mode to Debug (Xamarin Users)

Android Debugging with Logcat and Emulator. Is it possible?

This is pretty simple: I'm using NetBeans on Linux with Android emulator 1.6. I have Logcat on my android phone, but the process of getting the messages to somewhere readable isn't smooth at all.
Can someone tell me how to get Logcat running on the emulator? Is there anything I can do to see debug messages other then having to copy the apk to my phone and testing it?
Thanks in advance!
You have a few options for viewing the debug log output, assuming you have the SDK installed and your command path set up correctly:
Type adb logcat. The log output from the connected device or running emulator will appear. I usually prefer adb logcat -v time to see the time stamps.
Type ddms. This launches the stand-alone version of DDMS. It has a logcat display at the bottom.
Install the ADT extension for Eclipse, and open the logcat view. (Since you're using NetBeans I assume this isn't what you want to do, but I'm mentioning it for completeness.)
In all cases, the interaction is the same whether you're using a physical device or software emulator, because the ADB daemon conceals the details. Whatever you're doing for the device is also expected to work for the emulator.
If you have a device and emulator connected simultaneously, you can use adb -e logcat for the emulator and adb -d logcat for the device. From stand-alone DDMS or Eclipse, just pick the device or emulator from the pop-up menu.
If you have setup nbandroid you can find the adb logcat viewer in netbeans under:
Window -> Output -> ADB Log
--edit
Just followed up on the post above and started using C:\Program Files (x86)\Android\android-sdk-windows\tools\ddms which is alot better then the one in netbeans.
The SDK comes with a handy tool called ddms it should be in the tools folder of the SDK.
At the moment an Emulator is running, or a mobile phone is connected to your machine it should show up in ddms and you can see all the log output in ddms.

Emulator problem in Android

When I launch the emulator I face many problems (Errors):-
HttpConnectionApp]emulator-5554 disconnected!
Cancelling 'net.paxcel.http.HttpConnectionApp activity launch'!
Emulator]emulator: ERROR: the user data image is used by another emulator.
aborting
Each time I have to re-run it but all in vain.
How can I improve this so that I can re-run the application on same AVD?
I had the same issue after my computer locked up and I had to power cycle it.
Wiping the user data didn't fix my problem, I had to delete the following folders manually
C:\Users\%UserName%\.android\avd\AVD2.1.avd\cache.img.lock
C:\Users\%UserName%\.android\avd\AVD2.1.avd\userdata-qemu.img.lock
A quick-fix that obviously works is to restart the adb server each time this error occurs:
adb kill-server && adb start-server
Then, you simply run the application again (without restarting AVD) and that's it.
Run configurations → Target → Wipe user data → Run.
It fixed the problem in my case.
Here is the answer that helped me:
link text
Another solution for me is start the avd manager and start once emulator from there. After that everything turns to normal.
AFAIK, this happens when an emulator is started, but the Android Debug Bridge couldn't establish connection to it.
If you have just started the emulator with your application, watch if you get Waiting for HOME to launch... or something similar in your Console.
If you don't get that message, but the emulator has been started, chances are, you'll get into the ERROR: the user data image is used by another emulator situation again.
emulator: ERROR: the user data image is used by another emulator. aborting
Tried restarting the computer as I had done a lot of messing around earlier but no joy same error.
Went to shut down ADB so as I'm on XP I run > cmd then paste in > cd C:\Program Files\Android\android-sdk\platform-tools (the location of the location for the ADB on XP)
Tried
adb kill-server && adb start-server
Then moved the directories cache.img.lock and userdata-qemu.img.lock in the C:\Documents and Settings\.android\avd\ to a New folder (instead of deleting)
This worked fine.
Delete the existing emulators and then make a new one.
This worked for me, when I had this problem and couldn't find the folders to delete.
Under Run Configurations --> Target --> Add Command Line Options add this
adb kill-server && adb start-server
every time running your App will kill-restart the adb server.
It's probably a bad install of ADT. Try uninstalling the plugin, restarting Eclipse, then installing it again fresh.
That of you aren't letting the emulator boot all the way up and are closing it before ADT/ADB can install/run your app.
Please set wipe_data for emulator
Use same instance of application (after modification if any) to avoid error you are getting.
This can also happen if you're using a network share as your home folder, because some network file sharing systems may lock the image files.
Delete the directories cache.img.lock and userdata-qemu.img.lock (in my case these files are in /mylocalusername/.android/avd/avd7.avd
Thanks for this! Just to add for some people who develop in Windows XP.
The path to the avd directory can be C:\Documents and Settings\.android\avd
Thanks again for the answer! :)

Categories

Resources