Reputation: 5011
I am trying to run emulator on my android studio 8.14. When I click run it says it is already running. Any help would be appreciated.
AVD api21 is already running.
If that is not the case, delete the files at /home/sayem/.android/avd/api21.avd/*.lock and try again
Upvotes: 128
Views: 237167
Reputation: 1403
for Linux , create an executable script that contains this (depends on package psmisc ,Artix Linux):
#!/bin/bash
#kill x86 + x86_64 emulator instances
killall qemu-system-x86_64 -9
killall qemu-system-i386 -9
# delete all lock-files
for n in `find ~/.android/avd/ -name "*.lock"`; do rm -v $n;done
Upvotes: 2
Reputation: 879
For Linux this should clear them for all devices in one go if your issue is just .lock files
find $HOME/.android -type f -name '*.lock' -exec rm {} \;
Example with it just echoing out.
❯ find $HOME/.android -type f -name '*.lock' -exec echo rm {} \;
rm /home/mike/.android/build-cache.lock
rm /home/mike/.android/debug.keystore.lock
rm /home/mike/.android/avd/Pixel_6_Pro_API_33.avd/multiinstance.lock
rm /home/mike/.android/avd/Pixel_6_Pro_API_33.avd/hardware-qemu.ini.lock
rm /home/mike/.android/avd/Pixel_6_Pro_API_30.avd/multiinstance.lock
rm /home/mike/.android/avd/Pixel_6_Pro_API_30.avd/hardware-qemu.ini.lock
rm /home/mike/.android/build-cache/3.5.2.lock
~ at 10:16:27
❯
If you did not stop them all first can run this first beforehand.
adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done
Upvotes: 2
Reputation: 1125
When I was trying to delete multiinstance.lock it says
So, I opened Window's task manager and selected qemu-system-x86_64.exe and press End task
Upvotes: 20
Reputation: 161
I Also have the same problem but in ubuntu 20.04 and I had to navigate to /home/your_username/.android/avd/Pixel_2_API_28.avd/*.lock
and then delete all file with .lock
Note: you first need to enable show hidden files and I may have used different device (Pixel_2_API_28) from yours but it is applied to any device
Upvotes: 3
Reputation: 157
Check Updates... Emulator had an update. After I updated and restarted.. worked fine.
Upvotes: 0
Reputation: 1113
Go to (Windows)
C:\Users\directory.android\avd/Nexus_5X_API_26.avd
Or (Ubuntu)
~/.android/avd/name.avd/Nexus_5X_API_26.avd
and delete all files of with .lock extensions.
Upvotes: 4
Reputation: 1683
I tried solutions above but nothing worked so I deleted the emulator, restart pc and create a new one and it was resolved
Upvotes: 0
Reputation: 375
For Windows: Step By Step Instructions below:
Upvotes: 3
Reputation: 1211
EASIEST SOLUTION:
You're done :)
Upvotes: 1
Reputation: 5535
This working for me :
Invalidate chaches/ restart
Go to
1 - File
2 - Select Invalidate Cahes / Restart
Upvotes: 11
Reputation: 4573
Go to the down arrow and click on the "Show on Disk" link like attached image. You will get the list of all files, remove the file "hardware-qemu.ini.lock" and start again.
It works for me hope it will work for you too.
Upvotes: 56
Reputation: 1031
I'm don't know if some one is still having this problem, but, in my case, it's was an issue related to VAGRANT.... more precisely whit Virtual Box. I just stop the vBox proccess (i'm ussing ubuntu), remove the .lock files related to the emulator inself and that's it... the emulator should by ready to go.
Upvotes: 0
Reputation: 29
You can also solve this problem by doing "Invalidate chaches/ restart".
Upvotes: 1
Reputation: 322
Find and open the pid folder within your *.lock folder. Inside should be a number.
Kill pid:
Windows
taskkill /F /PID pid_number
Upvotes: 4
Reputation: 1112
If you have followed all answers, and no success yet. And not able to find that specific lock.
Search all .lock extension files in /avd dir, and remove them. After then start again emultaor. It works for me without restart system.
Upvotes: 0
Reputation: 8112
I closed the emulator, clicked the AVD Manager Icon on the menubar then under the emulators actions tab downward arrow I selected "Cold Boot Now" then ran the program normally by pressing SHIFT + F10
Upvotes: 1
Reputation: 1662
C:\Users\.android\avd
follow the path and open Emulator directory and delete all.lock
extension folders.
Upvotes: 0
Reputation: 3086
For MAC Users
Open Terminal, cd to the given path. List all the files using the command ls. You will see two files with .lock extensions or maybe more. Just delete those files.
Upvotes: 3
Reputation: 698
There are so many answer but i just extending to give answer of this question. What happen is when i follow Android Studio instruction and try to delete that folder Or file but i am not able to delete it, So what am i do is that i open the AVD Manager and click on down arrow which is on right side as you can see in below screenshot and click on stop after click on start and its working fine. There is no need to restart or recreate the AVD.
Upvotes: 19
Reputation: 1210
When you go to the specified location and try to delete those files sometimes you might get an error stating that the file or folder is already open or is used by another application
So the simple Solution is just to go to
Tools > Android > AVD Manager and Stop the AVD that you are trying to run
Then When you try to run the AVD again you might have the problem resolved
Upvotes: 3
Reputation: 490
For me, "delete .lock file" & "stop emulator then start" & "delete emulator then recreate" does't work.
but,delete "C/User/yourName/.android" folder can fix this problem
Upvotes: 3
Reputation: 19
Or you can type a command in terminal as
1.killall Finder
and then type,
2.defaults write com.apple.Finder AppleShowAllFiles true
it shows hidden .android folder
Open .android folder and delete .android/avd/Nexus_5X_API_26.avd/*.lock file
and now you run emulator it works fine.
Upvotes: 1
Reputation: 91
C:\Users\admin.android\avd\Nexus_5X_API_26.avd follow path and delete hardware-qemu.ini.lock this folder. make sure your problem can be solve :)
Upvotes: 5
Reputation: 4807
You don't have to completely delete the emulator when this happens. The files to delete should have a ".lock" extension:
You don't need to touch the configuration files.
You can easily find the files location by clicking on the arrow under the Actions tab (in the ADB manager), and selecting "Show on Disk".
Upvotes: 231
Reputation: 1152
In your Android Studio go to Tools->Android->AVD Manager. It will list your virtual devices. Click the Action column corresponding to your virtual device. It will list many actions. Click on Stop. This will shutdown your android studio. Now start android studio. Your virtual device should work fine.
Upvotes: 1
Reputation: 836
This worked for me:
Go to AVD Manager and click on the down-arrow on the right and click Stop. This stops the emulator and you can re-run it.
Upvotes: 64
Reputation: 1074
Upvotes: 1
Reputation: 492
Follow the instructions on the error and go to your
C:\Users\directory\.android\avd/Nexus_5_API_24.avd/*.lock
and delete all files with the .lock extension and it should work.
Upvotes: 19