ChatGPT解决这个技术问题 Extra ChatGPT

ERROR Android emulator gets killed in Android Studio

After updating to Android Studio 2 when I try to run my application and choose an emulator, I wait for the emulator to start and it suddenly gets killed. I can see the emulator process for some minutes but never the GUI. In Android studio, I get the error

android studio Error while waiting for the device: The emulator process for AVD was killed

This happens even if I run the emulator outside Android Studio. I have tried both an Android 6 and an Android 4.4-based emulator. Running on a Windows 7 x64 PC. Similar post to another StackOverflow post which was closed. I have tried various ram, VM heap, and resolution settings.

This happened mostly due to not enough space in c drive(min 4gb required),please clean c drive and check

S
Soc

I hit this issue trying to run Android API 30. In the end, I had to upgrade Android Emulator to 30.1.5 (it was 30.1.2 before this).

https://i.stack.imgur.com/neRmD.png


I am on macbookpro running Catalina 10.15.5 and this worked. Thanks for the tip
Nothing was working so I took the brute force route and just went to help -> Check for Updates... and chose "Update All" to update everything in the list. Then restarted the IDE. I repeated this (restarting about 3X) until no more updates appeared. Then started the emulator via "cold boot now" in the dropdown arrow in AVD "actions" column. I'm on the canary version of "Artic Fox" and after all this, the emulator is finally working.
This solved problem on Windows also. Had issue only when running API 30 (update emulator from 30.0.x to 30.3.5 fixed it)
Worked for Android S - API 31 - developer preview build
While i didnt have the same issue, this post is a good example of how if you update AVD< you have to check back in Android Studio that you have also dowloaded the matching SDK to make your app work with that new Emulator phone. not super "intuitive" :) thanks for the picture @Soc
J
Jim Simson

I had the same issue, the problem was there is not enough space in my disk drive.. you can see details about your specific situation in layer 'Event Log' this layer regularly is at the bottom on Android studio, it was my output Log:

"02:45 PM Emulator: emulator: ERROR: Not enough space to create userdata partition. Available: 3310.363281 MB at /home/user/.android/avd/my_Nexus_5X_API_27.avd, need 7372.800000 MB."

I had just 7 GB free, so just delete some GB's in my D.D. and it's working fine.


Clearing the disk worked for me. However, Event Log did not show any warning/error message of any kind that would indicate that disk space was the issue.
In AVD Manager, I edited the Virtual Device, clicked "Show Advanced Settings", and under "Memory and Storage", reduced the sizes of some of the storage options. Then I was able to run the AVD.
@Sau001 It sounds strange that the Log does not show the error, however it is good that it has worked you
FYI, for me I think the disk filled when doing the initial install of the avd in question. The AVD screen thought it was ok, but it wasn't. But removing ~/.android entirely and re-installing the images I wanted it started working. (the logs may have shown something before I closed studio and restarted, but I didn't check them then)
I too needed to clear the disk, but didn't see any message indicating this could be my issue. This worries me. If anyone can contribute how to view the emulator's error logs I would greatly appreciate it.
A
Alejandro

For me it seems it was a problem that OpenGL didn't work on my machine. I fixed it as follows:

Go to: Tools > Android > AVD Manager Press the "edit" (pencil) icon next to your AVD Change "Graphics" to "Software".


the "Graphics" options seems to only be available to devices without the Google Play Store enabled, as of Android Studio v3.5. Otherwise it stays set to "Automatic".
I couldn't change the settings because the field is muted to 'Automatic'. But I think the problem is potentially related to the graphic card, because after switching my gpu driver from X.Org X Server to Nvidia, the problem was resolved. I am using Ubuntu and always have graphics related issues.
Solved the problem but it is pretty slow in Software mode.
Thank you for your answer, after hours of searching and trying your answer solve the issue. Thanks
I
Iman Roosta

Check the free space of the emulator installation drive is more than 5 GB


In my case 5GB free space is not enough, after clean up to 20GB it works. Emulator nowadays might need more free space to run.
First in Emulator "wipe data" then start Emulator
Note that the host drive may have to have MORE space then you set for device (e.g. I had 14GB free on my disk, 10GB was device, but it still wasn't enough, when I made 40GB free on disk, it started working)
C:\Users\username\.android\avd check there. If you dont use some avd, delete them
S
Simon Schnell

Install the Intel x86 Emulator Accelerator worked for me.

https://i.stack.imgur.com/NWFgt.png


i had to do this and i also had to update the Android Emulator package
For me it was already installed but i had to update it. Thanks.
s
snehatilak

This worked for me:

Tools -> SDK Manager -> SDK Tools (tab) -> Deselect 'Android Emulator' -> OK

Now, when you try to run your app, or launch device from AVD Manager, it will give the 'Install Emulator' error -> Click Ok. This will automatically download the correct version.


and... increase ram memory. I changed from 1536 to 7536 MB RAM, and now it starts. Slowwwwly but it works for Android 11.0 x86 / API 30. Also the emulated performance graphics may fail when set to Hardware in some computers, so we can leave it as Software GLES 2.0
Not sure what helped - if freeing up space on the hosting disk (even there was enough space, I had to actually make much more) or this, but then it magically started working :)
S
Saurabh Padwekar

For Android Studio v4.1 and above:

Menu -> Android Studio -> Preferences -> Tools -> Emulator

Uncheck Launch in a tool window option.

https://i.stack.imgur.com/VDoAh.png


For me I was able to re-enable this setting after the emulator launched once as a standalone process. I.e. uncheck -> run emulator -> check -> run emulator.
then, this feature is not stable?
@AnggaAryaS This feature is new, so there are probably many bugs to be fixed
b
bkulov

This issue happens when you have two Android SDK installations on your machine and the environment variable "ANDROID_HOME" points to the wrong location.

To fix it go to Android Studio settings, find the proper Android SDK location, update the environment variable and restart Android Studio / your PC.

https://i.stack.imgur.com/1vLxY.png


the ANDROID_HOME changed after Installing Nativescript, and following your answer fixing the issue thanks
Had the same issue with nativescript. I have changed the path from c:\users\.... to C:\Android\android-sdk, then installed and upgraded emulators and everything started working.
This was it for me after trying 4 other solutions here :) Just a heads up, I needed to restart Android Studio for the new environment variable to take effect
S
SudhakarH

I resolved the same issue by updating the Android Emulator.

Steps:

1. In Android Studio Go to TOOLS
2. SDK Manager
3. Android SDK
4. SDK Tools
5. Update the Android Emulator.

Then it will Run.

Check this for reference https://stackoverflow.com/a/64384372/13952516


B
Baala

Faced a similar issue, tried the above solutions as well and it didn't work.

Would like to suggest a simple solution which could help if the above suggestions didn't address the issue.

Solution - Try cleaning up space in the system. My problem was I had only 1GB left while trying to launch the emulator after cleaning up space got 8GB and was able to launch the emulator.


Yeah, this solved my issue too. Obviously the simulated phone needs to use some Disk space for its memory and internal storage space.
I had the same problem. I did BIOS settings, virtualization, kvm, install different Android versions. All to realize, thanks to your comment, that I simply don't have enough space to launch it!
b
briosheje

https://i.stack.imgur.com/F3VvD.png

the events section clearly shows that ANDROID_SDK_ROOT was not set in my system.

In a nutshell, whenever you see such error when starting the emulator, just check the "events" section in the welcome to android studio screen to find the real problem.

Beware that if ANDROID_HOME is not set properly, it will still tell you that ANDROID_SDK_ROOT is broken.


In my case (AVD in Android Studio 4.1/MacOS Catalina) I had forced the ANDROID_HOME and ANDROID_SDK_ROOT in my ~/.zprofile. After commenting those lines and a reboot the AVD images started working fine: #export ANDROID_HOME=/usr/local/share/android-sdk #export ANDROID_SDK_ROOT=/usr/local/share/android-sdk I've also installed Intel x86 emulator as answered in stackoverflow.com/a/52327730/1245926 by @simon-schnell
v
vainquit

In my case, after installing the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019 (both x86 and x64 version), the issue is solved.

But wait! Why did I know this? I will tell you my experience.

When your program meets a bug, the first thing you need to do is finding the log to debug. But where is the log file that records all the events of the Android emulator? Click Help→Show log in Explorer. And then a new window is oepned, where a file called idea.log is located, and that log file is what we are looking for.

But this file may has recorded too much verbose info, so let's do following processes to get a more simple one:

·Exit Android Studio

·Delete the idea.log

·Open Android Studio

·Click Tools→ AVD Manerger

·Start one of emulators you have created, and needless to say, the error will occur again. But the idea.log will be created and the error is recorded into the log file now!

·Exit Android Studio.

·Open the idea.log and begin to analyze it.

·Search "emulator", and in my case there are 2 messages catching my eyes:

INFO - manager.EmulatorProcessHandler - Emulator: E:\cache\SDK\emulator\emulator.exe -netdelay none -netspeed full -avd Nexus_5_API_22 

INFO - manager.EmulatorProcessHandler - Emulator: Process finished with exit code -1073741515 (0xC0000135)

Obviously, the "exit code 1073741515" is something important, and actually many people have asked what it means in StackOverFlow, but unfortunately, I can't find any useful info about it. So let's pass it and focus on the first message.

Open the command line (Press "Win"+"R" → Enter "CMD" → Click "OK"), copy the above message E:\cache\SDK\emulator\emulator.exe -netdelay none -netspeed full -avd Nexus_5_API_22 and paste it to the command line. Press Enter.

I totally didn't know what this command meaned, but it's reasonable to deduce that Android Studio ran this command and resulted in the error, so I will try to reproduce the issue.

After that, an error window pop up, saying "...VCRUNTIME140_1.dll is missing...". I know I have been close to the answer. So I serch "VCRUNTIME140_1.dll Missing" on google, and people said that "downloading and installing both the x86 and x64 versions of the Microsoft Visual C++ 2015 - 2019 Redistributable will resolve this problem".

So I download both the x86 and x64 version and install them. After doing this, I run the emulator again, and everything goes well.


Thanks for the detailed explanation, it helps me to solve the problem. And for others, if you have separate versions installed like VS 2015, the combined package will replace it, you don't need to uninstall the separate version.
Thank you so much for explaining. You save my day.
Thanks! For me that was the key: "Click Help→Show log in Explorer. And then a new window is oepned, where a file called idea.log is located", a silly thing when you know it, essential when you don't!
l
liam spiegel

https://i.stack.imgur.com/DIbNs.png


In case already updated, just uninstall and reinstall android emulator from SDK Tools
A
Arghya Sadhu

Please check your free space on your disk also. I had a same problem and finally I got I need to free up space to fix this.


f
filiph

If you're on the Apple Silicon (M1) chip, make sure you're using an ARM64-based emulator:

https://i.stack.imgur.com/urapa.png

If you're not, create a new Virtual Device and use the arm64-v8a image from Other images.


It's strange that android studio doesn't recognize the architecture and not set it propertly. Worked!
Thank you for pointing this out... at least I can get something running in the emulator. Unfortunately, they don't have any images for the Android TV yet that seem to be working. Any idea how to run on Android TV? There are ARM images but none of them are ARM64
Doesn't fix it for me
M
Mohamed Mrzook

Go to: Tools > Android > AVD Manager and Press the "edit" (pencil) icon next to your AVD , Change "Graphics" to "Software".

work on my Windows 10 machine and ubuntu 18.04


I couldn't change the settings because the field is muted to 'Automatic'. But I think the problem is potentially related to the graphics, because after switching my gpu driver from X.Org X Server to Nvidia, the problem was resolved. I am using Ubuntu and always have graphics related issues (having integrated nvidia doesn't help :(.
Confirmed works for me - Remember to pick a device that lets you change this setting. (One without Google Play Store icon next to it) stackoverflow.com/questions/44328225/…
b
benjamin

If your username is not in ascii/ has spaces then this may help, as I tried all of the solutions here and couldn't fix this problem:

Note: I found this solution on this video, suggested by a user called "tatachka", this is her comment (she kindly let me share it here).

For example, I had this path c:\Users\Таня.android\avd\Nexus_One_API_24.avd My name in Windows is Таня, written in Cyrillic in windows encoding (cp1251). I changed the path to e:\Distribu\AVD.android\avd\Nexus_One_API_24.avd I moved files from disk C there and edited Nexus_One_API_24.ini changing the path in it and everything worked. How to change the folder path: My computer -> properties -> advanced system parameters -> environment variables - > lower 'New...' button: variable name: ANDROID_SDK_HOME variable value: e:\Distribu\AVD (in my case) After the reboot, a new folder(.android) appears in the folder e:\Distribu\AVD containing the 'avd' folder

EDIT: For clarification, the idea here is that you don't want the path to have non-ascii characters. I moved it to C:\programs_that_cant_read_hebrew (and preformed the other steps) and it worked just fine.

EDIT: changed "English" to "ascii/ spaces" after the comments


I just had exactly this. My surname has an Umlaut so the path to AVD included non-ascii chars. I got a warning that I should move the SDK because of this, but it doesn't warn about the AVD. The SDK location can be changed in the Android Studio SDK Manager but I had to set the environment variable ANDROID_AVD_HOME to the new location of AVD
My user name has spaces, and resulted in the same issue. moved it out of my user name and it worked perfectly.
R
RBrink

I get this same error if you upgrade the emulator to version 30+ and run mac < 10.15

You see the real error if you run it from commandline

~/Library/Android/sdk/emulator/emulator -avd

emulator: Android emulator version 30.5.3.0 (build_id 7196367) (CL:N/A)
dyld: Library not loaded: /System/Library/Frameworks/IOUSBHost.framework/Versions/A/IOUSBHost

You can fix this to upgrade to Big Sur or downgrade the emulator with these steps.

wget https://dl.google.com/android/repository/emulator-darwin-6885378.zip

unzip emulator-darwin-5395263.zip

mv ~/Library/Android/sdk/emulator ~/Library/Android/sdk/previous-emulator

mv emulator ~/Library/Android/sdk/emulator

cp ~/Library/Android/sdk/previous-emulator/package.xml ~/Library/Android/sdk/emulator/package.xml

Check if it succeed:

cd ~

~/Library/Android/sdk/emulator/emulator -version

28.0.25.0

~/Library/Android/sdk/emulator/emulator -list-avds

Source https://groups.google.com/g/flutter-dev/c/uEthfwjZBAQ/m/HSFqTgYsAgAJ

Edited April 8th 2021: I updated the emulator link to a newer version as mentioned in the comments


I downgraded the emulator with the version mentioned in stackoverflow.com/a/64301909/340175 which is a slightly newer release of the emulator than the one you're using AFAIK. Here's the link to it dl.google.com/android/repository/emulator-darwin-6885378.zip I've also raised an issue so Google are aware of the issue issuetracker.google.com/issues/183295965 you're welcome to 'star' the issue so they'll know how many people it's affecting.
İ
İsmail

My case was: GOOGLE PLAY.

My virtual device was Pixel 4... As shown on pic, Pixel4 has Google Play support, so that it give this error: " The emulator process for AVD Pixel4 was killed." It gives error on Android Studio 4.1.1.

So that, I created a new virtual device(Pixel 4XL) and selected "SOFTWARE" for emulated performance...

Because this device doesnt have Google Play support, it worked for me.

https://i.stack.imgur.com/taSdj.png


My case was the Graphics, it only worked once I selected Software. I wonder if it's a conflict with my Nvidia card...
t
teja bruice

goto tools>android>sdkmanager and update emulator and install related API level.It worked for me


k
ke Chankrisna

This was working for me. You must update to android studio to latest version and then follow step below to update sdk tool:

Tools -> SDK Managers Select Android SDK Tab on SDK Tools Check to update options available. Press ok button After that this procedure will take you some minutes, after it completed, everything will works fine.


c
cm101

Despite the question has been asked specifically for Windows, I will give my answer for MacOS 11.4 Big Sur, since this thread is the first hit on google when searching for this issue, and none of the answers already given solved the problem for me.

I found the solution to my problem here - for retention reasons, i will repeat the detailed steps anyway:

open Terminal and go to the directory /Users//Library/Android/sdk/emulator/qemu/darwin-x86_64/ create an xml file named entitlements.xml with the following content:

<?xml version="1.0" encoding="UTF-8"?>
     <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
     "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
     <plist version="1.0">
     <dict>
         <key>com.apple.security.hypervisor</key>
         <true/>
     </dict>
     </plist>

resign the emulator

codesign -s - --entitlements entitlements.xml --force qemu-system-x86_64

start the simulator


This fix worked great, I'm also on MacOS 11.4 Big Sur. The weird thing was that my Android emulator was working great before. Maybe I don't remember my MacOS updating 🤷‍♂️
h
hayashi-ay

For me it was a problem of available space left in my computer and deleting unnecessary files solved the problem. Causes are vary from situations and you should see event tab which detailed event log are showed.


J
Jonathan

To summarize the above:

Install and reinstall HAXM 7.5.6 (only available version) under 'Android SDK' settings. Try downloading it manually, even other versions (they don't work with Android SDK), installing it from the Android/Sdk folder, etc. sc query intelhaxm in cmd should show if it is running correctly. Virtualization is enabled in your BIOS and has been tested Made sure the PATH variables are correct (ANDROID_HOME / ANDROID_SDK_ROOT) but NOT (ANDROID_SDK_HOME) to the folder in your settings per Here. Otherwise, you will see EVENTS on the Android Studio splash screen. Try unchecking / rechecking Launch in a tool window in Emulator settings (and even Enable Device Frame in AVD settings) Try rebuilding in several different combinations of android, different phones, etc (but with same levels and packages ... 30 for example) Try Rebooting in several different configurations Make sure all SDK Tools are up-to-date, and even try a fresh install of Android Studio. However, tried removing all of them, and adding them back. Check your space, try to have 25GB maybe or more free Check for Virtual Box, Antivirus Software, etc. Open Android Studio with Administrator privileges

RUNNING ON DUAL MONITORS / DOCKING STATION ?

A) Run the emulator with everything unplugged, then plug back in your monitor! (Odd I know)... OR Better yet... B) Create a New Hardware Profile, which will enable you to change Graphics: Automatic to Software.


Rebooting works after making configurations.
For me the problem was launching the emulator while the external monitors were connected through a USB dock. If I unplug the dock, the emulator launches just fine and keeps running after plugging the dock back in. Edit: Setting the laptop display as the primary monitor and launching the emulator, without unplugging the dock, also works.
I
Imtiyaz Khalani

I know so many people have given answers to this question many have valid points as well. I have tried all the above possible ways, but it was not working, after reading logs from the android studio, I came to know it was a storage issue, for the emulator keep 11 GB space free and it will work.


P
Prahlad Awasthi

In Android Studio Go to Help -> Show logs in explorer Try to run the Emulator again of the errors are as below :

handleCpuAcceleration: feature check for hvf cannot add library vulkan-1.dll: failed cannot add library vulkan-1.dll: failed

Then install Microsoft VS Code and go to below path

C:\Users\AppData\Local\Programs\Microsoft VS Code

Copy the vulkan-1.dll and paste in below path

C:\Users\AppData\Local\Android\emulator\lib64

For me this solutions worked


B
Bacar Pereira

Simple solution 2021

Go to AVD Manager Find the emulator you are trying to use and then click on the down arrow Select the option Show on Disk delete every file that ends with .lock Runs again the emulator and after this will initialize


N
Niang Moore

For me, just deleting ANDROID_SDK_HOME from the environment variable list solved the problem


Which environment variable list?
Whoa! This was the one that worked me: / Thank you very much hehe!
K
Kidus

I tried every single answer in here but none of them worked, but finally I got it working when I run it on an emulator device with Android API 28. I think the problem is the emulator device couldn't run Android API 30.

https://i.stack.imgur.com/FE2aA.png


N
Narendra talapara

I think this is problem of Android studio 2 Update or Problem to solve please Update also Android sdk version also then work properly.


I have updated the android studio and the related SDKs but still same issue. find the attached screenshot link (i.stack.imgur.com/rgfgx.png)