I am new to Android Studio and I am having problems while using the emulator. When I try to run it keeps crashing saying:
"Cannot launch AVD in emulator" [6816]:ERROR:./android/qt/qt_setup.cpp:28:Qt library not found at
C:\Users\Jay\AppData\Local\Android\Sdk\emulator\lib64\qt\lib
Could not launch 'C:\Users\Jay\AppData\Local\Android\Sdk\emulator/qemu/windows-x86_64/qemu-system-i386.exe':
No such file or directory
I have enabled VT-x from BIOS settings yet I am having the problem. I have searched a lot and cannot find an answer. Any help will be much appreciated. Can anyone give me a solution?
Screenshot of error
This seems to be an issue relating to the recent update. A temporary solution is to launch emulator from within the /path/to/android-sdk/tools directory in the commandline.
See https://code.google.com/p/android/issues/detail?id=235461 to follow the issue.
All other answers did not work for me as "Android Emulator" was not installed with a standard installation of Android Studio. Make sure you have installed it and then try other answers if required.
For Linux or Mac systems you can add the following to ~/.profile (or ~/.bashrc):
function emulator { cd "$(dirname "$(which emulator)")" && ./emulator "$#"; }
then run to load the changes:
source ~/.profile
(or source ~/.bashrc of course)
This will allow to execute emulator until they fix the issue
(based on #10 yanokwa comment from https://code.google.com/p/android/issues/detail?id=235461)
I've installed the latest Android Emulator 26.1.2 which has solved this problem.
Btw if in your PATH you have both of this:
C:\AndroidSDK\tools
C:\AndroidSDK\emulator
The emulator command will try to use the emulator.exe inside the tools folder, which is not working.
To solve this in your PATH you need to move C:\AndroidSDK\emulator
in the line before the tools directory, in this way the emulator
executable will be searched inside the emulator folder first and will
take precedence over the one present in the tools folder
MacOS:
If you have a Mac you can move
~/Library/Android/sdk/emulator before
~/Library/Android/sdk/tools
a simple solution is to add this alias to your .bashrc .profile or equivalent
alias emu="$ANDROID_HOME/tools/emulator"
then source .bashrc or .profile or just simply open a new terminal
finally running your emulator will be as simple as emu -avd name
Zsh users can add:
function emulator { ( cd "$(dirname "$(whence -p emulator)")" && ./emulator "$#"; ) }
to .zshrc (or .zshenv).
Load changes to current shell by sourcing changed file:
source ~/.zshrc
Now you can use emulator command in zsh.
Thanks to J. Costa for his answer for bash.
I had same problem with latest Android Studio installed just yesterday on Macbook.
Though the emulator binary was available in the sdk/tools folder, Android Emulator package wasn't installed. Selecting Android Emulator in Android Studio->Preferences->System Settings->Android SDK, downloaded the emulator package and installed it.
After the emulator installation, I am able to launch the emulator.
First of all, the issue thread on Google Issue Tracker was already resolved. You don't have to set environment variable like LD_LIBRARY_PATH as a workaround any more. But you have to upgrade your Android SDK and use the LATEST emulator package (binaries). Without having that, you'll still see the annoying QT errors.
Then, it's crucial to make sure that the required SDK packages are installed to launch an emulator. When installing a specific emulator image by sdkmanager, it won't check or ask you to install required dependencies. Whenever you see error complains about ANDROID_SDK_ROOT, such as PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT or PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value, it's exactly because of that.
So the 3 other essential dependencies apart from the emulator image are:
platform-tools
platforms;android-<api_level>
emulator
Which you can install via:
sdkmanager "platform-tools" "platforms;android-<api_level>" "emulator"
The api_level is the same API level your emulator image is.
For those who are still experiencing the issue even when performing the command from .../Sdk/tools directory, try adding the -use-system-libs argument.
So it should be in the following format:
path/to/Sdk/emulator -use-system-libs -avd [AVD-NAME]
For me, here is an example:
/home/cillian/Android/Sdk/emulator -use-system-libs -avd Nexus5
I had the same problem and I solved it by installing the emulator cause somehow the updates seem to have deleted it. Do that from Android Studio tools-> SDK manager. Hope this helps
I see that you should only add below into the path to be able to launch emulator
C:\Users\Ram\AppData\Local\Android\Sdk\platform-tools
C:\Users\Ram\AppData\Local\Android\Sdk\emulator.
After installing Android Studio 3.0 and higher, I see that C:\Users\Ram\AppData\Local\Android\Sdk\emulator has same files as C:\Users\Ram\AppData\Local\Android\Sdk\tools
The tools folder is missing some files, so remove the tools folder from path.
You can use below emulator commands to launch emulator from command prompt:
emulator -list-avds
emulator #Pixel_2_XL_API_26 - Based on the avd that you have setup
I have installed Android Studio 2.3.3 (today 2017-08-01) on windows 10 x64
Same issue.
I have manually installed emulator from Android Studio -> Tools -> Android -> Sdk Manager -> SDK Tools -> Android Emulator (version 26.1.2)
After installation ... same issue
I have added my path from emulator folder to my environments variables before tools path (like as one answer above) but still same issue.
Then I have deleted emulator.exe and emulator-check.exe from tools folder and this solved for mi the issue
Follow these steps to resolve that problem (Windows 10):
Check in Android studio if you installed Android emulator, if not, install it.
Check in Android studio if you installed Intel x86 Emulator Accelerator (HAXM installer), if not, install it.
In Environment variables => System variables edit "Path". You need to add this line for emulator: %ANDROID_HOME%\emulator before %ANDROID_HOME%\tools and %ANDROID_HOME%\platform-tools (The third step was a solution for me.)
For Mac
If have create emulators, try this shell code:
#!/bin/bash
cd /Users/***/Library/Android/sdk/tools/
avds=`emulator -list-avds`
echo "show All emulators"
i=0
for item in $avds
do
echo [$i] $item
let i+=1
done
read index
avds=($avds)
# echo ${avds[$index]}
emulator -avd ${avds[$index]}
*** is your user name
This problem seems to be fixed in Cordova version 7.0.X
If you are using Cordova version 6.5.0 you can fix it easily.
The root of the problem is in the emulator.js file located from the root of your project directory at ./platforms/android/cordova/lib/emulator.js
Simply update the following line, (for me it was line 205):
.spawn('emulator', args, { stdio: 'inherit', detached: true})
to
.spawn('emulator', args, { stdio: 'inherit', detached: true, cwd: process.env['ANDROID_HOME'] + '/tools'})
This will fix the relative path issue your are experiencing.
Also, there is a second fix needed for the Cordova version 6.5.0 on line 56. Simply drop the letter "s" from the word "avds" plural, to make it "avd" singular.
I was facing this issue
java.io.IOException: Cannot download
'https://dl.google.com/android/repository/emulator-windows-4266726.zip'
I updated to studio 3.0 in windows 10, my emulators stopped working.Things I did for fixing,
Deleted previous installation folders of android studio like 2.0 and 2.1 present under my username alongside .AndroidStudio3.0 folder(leaving it untouched).
Deleted previously installed emulators which any way stopped working.
Downloaded the emulator zip file manually from the link above.
Pasted its contents in emulator folder of
C:\Users\myusername\AppData\Local\Android\Sdk\emulator
Created a new emulator and started it, Bingo! it is working!!
My android studio is in the windows operating system. but most of the answers in this page do not work for me.
but I figure it out with an easy way.
In your android studio IDE, open the [Sdk manager], check if you have downloaded the [Android Emulator] and [Android SDK tool]
How to check them?
[SDK Manager] -> [Appearance & behavior] -> [System Setting] -> [Android Sdk] -> There are tabs here and choose the second one [SDK tools]. then check [Android Emulator] and [Android SDK tool].
Hope that it can help you.
Good luck!
I just solved this issue for headless emulator scenario So If I checked my andrdoid_sdk folder there are 2 executable emulator. The issue is sitting one the version
${ANDROID_HOME}/emulator/emulator
version 29.3.4
no issue
and the second one is
${ANDROID_HOME}/tools/emulator
version 26.0.3
QT issue
so make sure you're using latest emulator version especially if you need headless emulator as stated on : https://androidstudio.googleblog.com/2019/02/emulator-2818-canary.html
cd $ANDROID_HOME/tools then emulator --avd #whatever_name_it_is
It seems I was having same problems with emulator in tools folder and AS 4.1.1. A quick solution that I've found for Mac users to work with the new emulator of the emulator folder is to specify the whole path to it:
~/Library/Android/sdk/emulator/emulator <device> <flags>
I was trying on Mac and facing the similar challenge. Mistakes I was doing, is adding PATH before to ANDROID_HOME which should be come at the end. Below is my zshrc file which worked.
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home
export ANDROID_HOME="/Users/rohitmandiwal/Library/Android/sdk"
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
Installing Android emulator will solve the issue as this setting is not by default enabled in android studio. In android studio 3+ onwards you cannot find it under Tools-->Android-->Sdk Manager -> SDK Tools -> Android Emulator but it's under File-->Settings-->Appearance &Behavior-->System Settings-->Android SDK-->SDK Tools-->Android Emulator
I manage to solve this error. In my system varible i need to set ANDROID_HOME
For my User variable i need
both these path
C:\Users\tonyhudson\AppData\Local\Android\Sdk\platform-tools
C:\Users\tonyhudson\AppData\Local\Android\Sdk\emulator
Remember to delete C:\Users\tonyhudson\AppData\Local\Android\Sdk\tools because it will cause the error
When you have installed only Android SDK and not Android studio. You need to find out the path of the emulator and execute with full path. For example,
/usr/local/share/android-sdk/tools/emulator #test
This should resolve your problem. At least this is what worked for me.
I added the following to my ~/.zshrc file and it worked. (M1 Pro Macbook)
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home
export PATH=$ANDROID_HOME/emulator:$PATH
Remember to do source ~/.zshrc after editing it.
My problem turned out to be that I was running VirtualBox at the same time as the emulator. For anybody else running into this problem, have a look here: Android emulator and virtualbox cannot run at same time. Hopefully one of the answers will give you a working solution.
You can also just open the Tools > AVD Manager from Android Studio and start the emulator manually.
There can be the bugs / updates happened in the underlying OS. So, instead of updating in .profile, /etc/environment, or .bashrc file to point adb, emulator etc, put (copy and paste) all the emulator folder inside /usr/bin directory. This /usr/bin is by default pointed by the system. Install adb tool from the terminal. This should solve everything.
And/Or, update your all environment variables in /etc/bash.bashrc file. Note that: /etc/bash.bashrc file is what gets executed everytime you open the bash terminal.
If you're using a Docker container which is running a Ubuntu x86 image, it may not be possible to run an x86-based emulator within the Docker image. You will either get the "Qt library not found" error or the "Please ensure KVM is properly installed and usable" error (more info here).
An alternative is to use an ARM-based emulator, which are easier to run, although they are slower:
# Download an ARM emulator image
android-sdk/tools/bin/sdkmanager "system-images;android-24;default;armeabi-v7a"
# Create an ARM-based emulator AVD with 250 MB SD card
avdmanager create avd -n Android_7.0_API_24 -k "system-images;android-24;default;armeabi-v7a" -c 250M --force
# Check the image is properly created and available to run
android-sdk/emulator/emulator -list-avds
# Run the emulator
android-sdk/emulator/emulator -avd Android_7.0_API_24
More info: https://medium.com/#AndreSand/android-emulator-on-docker-container-f20c49b129ef
A solution that worked for me that I've not seen here before is to link android-sdk/emulator/emulator to android-sdk/tools/emulator.
Dumb? Genius? worksforme.
With 25rc1 of the SDK tools I am having a problem when starting the emulators from $PATH
➜ ~ which emulator
/home/ligi/bin/android-sdk/tools/emulator
➜ ~ emulator #M
Could not launch './qemu/linux-x86_64/qemu-system-i386': No such file or directory
➜ ~ /home/ligi/bin/android-sdk/tools/emulator #M
console on port 5554, ADB on port 5555
Anyone knows a workaround? I could write a script to start emulators and cd in tools before but perhaps there is a better solution.
I encounter this one in android studio 2.3 which use new path for the emulator so try the following:
do not use emulator executable in the: sdk-path/tools/ directory but instead use the one found in the : sdk-path/emulator/
and also remove or rename the emulator found in the sdk-path/tools directory.
and because android sdk shipped with it's own libstdc++.so.6 you need to do the following to avoid the libGL error:
cd $ANDROID_HOME/emulator/lib64/libstdc++
mv libstdc++.so.6 libstdc++.so.6.bak
ln -s /usr/lib64/libstdc++.so.6 $ANDROID_HOME/emulator/lib64/libstdc++
Try this, it work for me on Windows.
Tools -> Android -> SDK Manager -> SDK Tools -> Android Emulator
Then click on Apply.
If you're launching the emulator from command-line, try setting the current directory to your android sdk "tools" folder first.
This works for me as a workaround:
pushd ${ANDROID_HOME}/tools
emulator -avd ${EMULATOR_NAME} -wipe-data&
popd
This one works for me on MacOS Sierra.
Preference -> Appearance & Behavior -> System Settings -> Android SDK -> SDK Tools (tab)
Tick on Android Emulator and Apply
I had the Android Emulator up to date under SDK Tools. But I was still getting the error. Adding the following line to ~/.bash_profile solved the problem for me:
PATH=$ANDROID_HOME/emulator:$PATH
In Ubuntu 19.10!
With the environment variables already configured ($ANDROID_HOME), you should be able to list the AVDs, but if you are unable to start the AVD, do the following:
# Check the AVD target name
emulator -list-avds
# But to start do:
$ANDROID_HOME/emulator/emulator #avd_name
or
/home/$USER/Android/Sdk/emulator/emulator #avd_name
Make sure that ANDROID_EMULATOR_FORCE_32BIT is not set in your environment
In Virtual device configuration, set Emulated performance to Software GLES 2.0
yah my dns is blocked in the region i am visiting so i was searching for a way to add dns servers and start emulator at command line. default emulator in path did not work. instead go to your android SDK home and you'll see a emulator in there. use that emulator executable like this:
emulator -avd Nexus_5X_API_26 -dns-server 8.8.8.8,208.67.222.222,199.85.126.10,8.8.4.4
i think you can give 4 dns's. anyway this is a side note. back to the issue:
people here did not mention much that you need the -avd flag with it. wanted to point that out.
Do not use $ANDROID_HOME/tools/emulator, it will cause error when you launch every time unless you change dir.
There is a another emulator in $ANDROID_HOME/emulator.It is a good choice
How to open the AVD manager on Ubuntu Linux from the command line?
For thoose coming here because the android avd command has been deprecated*, here's how to do it now:
Using Android Studio
Open Android Studio with a valid studio project (if you don't have one, simply create one empty). After you've your project open, go to Tools => Android => AVD Manager. Note that this menu does not appear if you don't have a valid Android Studio project open.
Now you can safely close Android Studio if you only want the AVD Manager.
From command line
If you want to use the command line you'll first need to create the virtual device using avdmanager, located under $ANDROID_HOME/tools/bin/avdmanager like so:
$ANDROID_HOME/tools/bin/avdmanager create avd --force --name testAVD --abi google_apis/x86_64 --package 'system-images;android-23;google_apis;x86_64'
After you created the device to emulate, then you need to open it with emulator, which is located under $ANDROID_HOME/tools/emulator. The command for the previously created device should be something like:
emulator -avd testAVD
If it crashes saying something like...
[140022905190208]:ERROR:./android/qt/qt_setup.cpp:28:Qt library not found at ../emulator/lib64/qt/lib
Ensure you're running the emulator command inside the $ANDROID_HOME/tools folder, otherwise may not work.
If you already added a device VM you can list them all with
emulator -list-avds
Check out the official documentation for more details (thanks to Jeff Xiao for this—in comments).
* The depreaction note says:
The android command is no longer available.
For manual SDK and AVD management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
Use android avd to open the AVD Manager.
For me, ./android avd worked, where android was the shell script under android-studio/sdk/tools.
Sadly commands android sdk and android avd stopped working so to run emulator we need to use different commands to download and build all devices and its dependencies:
Download sdk-tools-linux (tar.gz) from:
https://developer.android.com/studio#downloads
Unpack tools to : ...android-sdk/tools (...wherever you want)
Go to : android-sdk/tools/bin
Install needed sdk libraries:
Execute in cmd
sdkmanager --update
sdkmanager "platform-tools" "platforms;android-29"
sdkmanager "build-tools;29.0.1" "extras;android;m2repository" "tools"
sdkmanager "system-images;android-29;google_apis_playstore;x86_64"
sdkmanager "emulator"
Setup environment variables
Add env to system by editing ~/.bashrc (Linux) in Windows just setup system enviroments.
export ANDROID_HOME=../android-sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
alias emulator="sh $ANDROID_HOME/tools/emulator"
Note: There is possible that You need JAVA_HOME too.
Restart computer or cmd to load environments
Create device:
Go to /bin
avdmanager create avd -n myDevice -k "system-images;android-29;google_apis_playstore;x86_64"
run device:
Got to dir and run
cd android-sdk/tools
emulator -avd myDevice (or sh $ANDROID_HOME/tools/emulator -avd myDevice)
Issues:
qemu emulator not found in /bin....
cd android-sdk/tools/bin
ln -s android-sdk/emulator/ emulator
./android avd is deprecated use ~/Android/Sdk/tools/bin/avdmanager --help instead!
or if it is easier for you, move to the directory and use it like in the old version:
cd ~/Android/Sdk/tools/bin/
./avdmanager
check new [options] with --help or -h before you use avdmanager
first occurence in Android Studio 2.3 !
Android studio:v3.0.1
Get name:
/home/user/Android/Sdk/tools$ android list avd
Start emulator:
/home/user/Android/Sdk/tools$ emulator -avd Nexus_6_API_23
First of all to show all devices
run the following command from the location - ~/Android/Sdk/tools
/home/user/Android/Sdk/tools> ./emulator -list-avds
then you will see the list of devices id, in my case i got following devices
Nexus_5X_API_28
Nexus_9_API_28
Now just run following command with the device id you want to run.
/home/user/Android/Sdk/tools> ./emulator -avd Nexus_9_API_28
I created shortcut with this command
/path/to/Android/emulator/emulator -avd Nexus_5X_API_26
Where "Nexus_5X_API_26" is my virtual device I created in Android Studio (2.3.3). Correct name can be checked from ~/.android/avd/ folder, where are one subfolder (with extension .avd) and one file (with extension .ini) for each. There are qcow2 files which I think could be also run directly with qemu (have not tested yet).
I used a sudo bash command and that worked for me:
sudo ./avdmanager list
Here's the command-line usage for creating an AVD:
android create avd -n -t [- ] ...
Example :
android create avd -n my_android1.5 -t 2
If the target you selected was a standard Android system image ("Type: platform"), the android tool next asks you whether you want to create a custom hardware profile.
Android 1.5 is a basic Android platform.
Do you wish to create a custom hardware profile [no]
Use the create avd command to create a new AVD, specifying the --skin option with a value that references either a default skin name (such as "WVGA800") or a custom skin resolution (such as 240x432). Here's an example:
android create avd -n -t --skin WVGA800
or you can refer from :-
http://developer.android.com/tools/devices/managing-avds-cmdline.html
If for example I have simple android project and I want to run it from command line of Android Studio. How can I do that? I want to enter some commands into command line:
ant debug adb install bin/MyFirstApp-debug.apk
Where can I find command line in Android Studio? Thanks for any help.
Update:
New location in Android Studio: View -> Tool Windows -> Terminal.
Also, the default keyboard shortcut is alt + F12.
Old:
Go to Tools -> Open Terminal. Works great.
I've tried to use the Windows terminal to do the cmd like "adb logcat", but it says "adb is not recognized."
So I just found a solution provided by the following link, which works fine for me:
https://www.youtube.com/watch?v=yjutSsQn2Ic
Steps to setup adb on windows :
1) Open command promt and type adb
you will see this message :'adb' is not recognized
2) Now Download sdk(adt bundle) from
http://developer.android.com/sdk/index.html
the ADT Bundle includes everything you need to begin developing apps: Eclipse + ADT plugin Android SDK Tools Android Platform tools The latest Android platform The latest Android system image for the emulator
3)Extract the zip to c drive with name "AndroidSDK" Open the platform-tools folder, you will find the adb.exe file
4)Now click on my computer and select properties
5) Click on advanced system settings
6) Choose environment variables
7) From system variables, choose path and double click on it
8)At the end of variable values put a semicolon ;
and address of platform tools folder,
for me it is
C:\AndroidSDK\platform-tools
9)Now click OK
10)Open command prompt and type adb
11) You will see it is working
View -> Tool Windows -> Terminal (Alt + F12)
appears to be the menu navigation for newer versions of Android Studio (1.2.1.1, at this time)
To open terminal in android studio Android Studio Arctic Fox
View -> Tool Window -> Terminal (or) Alt + F12
You can either run your apk on an emulator or directly on a device via the adb CLI.
Devices
Find your preferred plugged in device ID:
adb devices
Install onto your device (or emulator if no device ID) with the following command:
adb -s "your-device-ID" install bin/MyFirstApp-debug.apk
You can also run with the following command:
adb shell am start -n com.app.name/com.app.name.LaunchActivity
Emulators / AVDs
List your emulators:
emulator -list-avds
Run a specific emulator:
emulator -avd device_name
eg:
emulator -avd Pixel_5_API_30
When i enter "adb install asdasd.apk" to cmd returns "error:device not found". How can I fix this?
Just copy that apk file into ( D:\android-sdk\platform-tools ) android sdk platform tools.
and then open the cmd prompt.
then, come into that platform tools path in cmd prompt.
then, give like this in cmd -- adb install (appName).apk
wait few minutes and get success respomse in cmd prompt..
First, familiarize yourself with a concept of AVD. That's basically an instance of the emulator - it has a bunch of settings, like the Android version to use and screen size and an SD card image.
You cannot install stuff "in the emulator" - you can only install stuff into a specific AVD. For that, you need to create and run an AVD first. For that, use "AVD Manager" from Eclipse or standalone.
Under the Android SDK folder in Explorer, run "AVD Manager". Choose an AVD (or create a new one if you don't have any). Select, click "Start".
Does the emulator show up when you run the following command?
adb devices
If not, you might have to boot up the AVD first, but if I remember correctly it should be starting it up by itself.
Have you created a new emulator for your project? And are you using Eclipse? Eclipse has an ADT plugin which is useful as it allows you to open the AVD manager through it. This plugin will give you this option in the Windows tool bar of Eclipse: Windows>AVD manager.
Create a new project based on the emulator and click the run button which will install your project onto the emulator. If you have an Android device I recommend turning USB development mode in your phones settings and running your project straight onto your device as it will be a lot faster. Hope this helps
this is what i did :
first run the "AVD Manager"-> choose an AVD -> click "Start"
immediately after
you click on "Start"
use command on cmd as,
adb install asdasd.apk
then in my case (Windows), asked to place .apk file in data/local/tmp/
what i did was copy and paste .apk file into data/local/tmp
and again use command
adb install asdasd.apk
then cmd prompted-> Success
You can also use command
adb devices
command for check whether emulator is in the list
Actually you may need to run AVD several times