PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value



After typing cordova run android in terminal, I'm getting this error:


cordova run android


Waiting for emulator to start...
PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value [/Users/username/Library/Android/sdk]!



This happens after exporting:


export ANDROID_SDK_ROOT='/Users/username/Library/Android/sdk'



Before exporting I got:


Waiting for emulator to start...
PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT



Any ideas where I'm going wrong? I'm sure this is the sdk root so why am I getting broken avd system path?





Do you manage to launch the emulator with AVD Manager ?(located in <AndroidSDK>AVD Manager.exe)
– e666
Sep 22 '16 at 20:46





I'm facing this very same issue on Visual Studio as well while creating cross platform app. My error text is 1>PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT 1>Emulator Nexus_5X_API_23 cannot be started.
– RBT
Oct 24 '16 at 5:07



1>PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT 1>Emulator Nexus_5X_API_23 cannot be started.





I just opened Android SDK manager and installed everything which was there (Tools, Various API levels, Extras). Literally! It solved my problem. Although, I faced further problems after that which were related to Intel's HAXM technology required for running Android emulators. They have to be solved differently.
– RBT
Oct 24 '16 at 11:32





Possible duplicate of Cannot run emulator in Android Studio
– coelhudo
Nov 20 '16 at 23:34




18 Answers
18



On Mac:
I had installed android-sdk using brew as well as Android Studio. Somehow, having 2 installations was causing this problem. When I uninstalled my brew installation of the sdk using brew cask uninstall android-sdk and added the following vars to my env. It worked.


android-sdk


brew


brew cask uninstall android-sdk


export ANDROID_HOME=/Users/<Username>/Library/Android/sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME





I had previously installed the android sdk using brew whilst following a Nativescript tutorial. After installing Android Studio I found the emulator wouldn't launch. Your fix solved my issue. Thank you!
– Cocoanut
Oct 13 '17 at 21:56





This worked for me too. I had also installed android-sdk during the NativeScript install. The emulator fires up directly from Android Studio now, But not through NativeScript (tns run android)
– Paralellos
Dec 11 '17 at 2:29


android-sdk





Also worked for me, just remove brew one and it worked!
– Majid
Dec 26 '17 at 21:20





Yep, this worked for me too! Thanks!
– Big Rich
Feb 13 at 0:19





It solved my issue, but without deleting brew's android-sdk version.
– mrisek
Feb 15 at 22:37



There are may be several different problems when you move your AVD or SDK to another directory, or replace an old SDK with a new one, or somehow get the SDK corrupted.



Below I'll describe all the possible problems I know, and will give you several ways to solve them.



Of course I assume that you have any AVD created, and it is located in C:Users<user_name>.androidavd (Windows) or ~/.android/avd (Linux/MacOS).


C:Users<user_name>.androidavd


~/.android/avd



If you moved .android to another place then set the ANDROID_SDK_HOME environment variable to the path of the parent dir containing your .android and make sure the AVD Manager successfully found your Virtual Device.


.android


ANDROID_SDK_HOME


.android



Also check paths in <user_home>/.android/avd/<avd_name>.ini


<user_home>/.android/avd/<avd_name>.ini


PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT
PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value



These 2 errors happen if the emulator cannot find the SDK, or the SDK is broken. So, first of all I recommend to remove the ANDROID_SDK_ROOT variable at all. It's only needed when the emulator is located outside of the SDK directory. But in general, your emulator stays inside the SDK dir. And in this case it must detect the SDK location automatically. If it doesn't, then your SDK probably has wrong filetree. Please do the following:


ANDROID_SDK_ROOT



Check that the SDK directory has at least these 4 directories: emulator, platforms, platform-tools, system-images. It is very important! These directories must be present. If some of them don't exist, then just create empty dirs.


emulator


platforms


platform-tools


system-images



Go to <user_home>/.android/avd/<avd_name> and open config.ini. Find the image.sysdir.1 property. It points at the directory inside SDK containing system images. Make sure that this directory exists and contains files like build.prop, system.img, etc. If it doesn't, then you have to open the SDK Manager and download system images your AVD requires (see below).


<user_home>/.android/avd/<avd_name>


config.ini


image.sysdir.1


build.prop


system.img



If everything's set up properly, when these errors about ANDROID_SDK_ROOT must be gone. If they're not, then now you may try to set up ANDROID_SDK_ROOT variable.


ANDROID_SDK_ROOT


ANDROID_SDK_ROOT



The next problem you may face is that the emulator starts to launch, but hangs up or quits immediatelly. That probably means that you don't have all the required packages installed.



Another possible error is:



Could not automatically detect an ADB binary. Some emulator functionality will not work until a custom path to ADB is added in the extended settings page.



So, to successfully launch any AVD you must be sure that at least these packages are installed:


emulator (Android Emulator)
platform-tools (ndroid SDK Platform-Tools)
tools (Android SDK Tools)



And as I mentioned earlier you must install system images your AVD is using, for example system-images;android-25;google_apis;x86


system-images;android-25;google_apis;x86



Note that the most recent versions on SDK don't have a standalone SDK Manager.exe. Instead of it you have either to use Android Studio, or toolsbinsdkmanager.bat (Linux/MacOS probably have sh files).


SDK Manager.exe


toolsbinsdkmanager.bat


sh



To list all available packages use sdkmanager --list or sdkmanager --list --verbose


sdkmanager --list


sdkmanager --list --verbose



To install packages use sdkmanager <package1> <package2> ...


sdkmanager <package1> <package2> ...



Also I recommend to install HAXM on your system manually.



The last problem I'll mention happens when you're trying to move AVD or SDK from one computer or directory to another. In this case you may get such error:



qemu-system-i386.exe: -drive if=none,overlap-check=none,cache=unsafe,index=0,id=system,file=C:Users<old_user_name>.androidavd<avd_name>.


C:Users<old_user_name>.androidavd<avd_name>



avdsystem.img.qcow2,read-only: Could not open backing file: Could not open '<old_sdk_dir>system-imagesandroid-22google_apisx86system.img': Invalid argument


<old_sdk_dir>system-imagesandroid-22google_apisx86system.img



There are 2 ways to fix it:



If you don't care about the data the AVD contains, just delete all the qcow2 files from the AVD directory (e.g. from <user_home>/.android/avd/<avd_name>). In this case you will get a clean version of Android, like after a hard reset.


qcow2


<user_home>/.android/avd/<avd_name>



If the data on the emulator is important to you, then open all qcow2 files one by one using any HEX editor (I prefer HxD), find the path of a base img file, and change it to the correct one in the Overwrite mode (to preserve the file size). Then select the path and get its length in hex (e.g. 2F). 2F represents the ASCII slash /. Put it into position 13:


qcow2


img


Overwrite


2F


2F


/


13



Edit Android qcow2 files using HxD HEX editor



PS: Not sure, but there are probably some utilites like qemu-img allowing to set different base image. Well, to me it's easier to manually edit the binary.



Now you'll probably be able to successfully launch your Android Virtual Device. I hope so :)





You, sir, are magnificent.
– Chisko
Jul 9 '17 at 20:19





wow this is like the most hackish solution i have ever seen! Amazing!
– Steven Yap
Aug 24 '17 at 6:54





Another reason can be missing hw.cpu.arch in the config.ini
– daserge
Sep 15 '17 at 10:51


hw.cpu.arch





I followed all instructions and I still get broken AVD system path.
– rolls
Oct 8 '17 at 2:36





Awesome. Well done with the qcow base files! Do you know about a more generic way to rebase the qcow files? I would like to share my AVD with several people...
– Amit Moran
Nov 5 '17 at 16:04



It means that your path to tools is incorrect. This is what it looks like on a mac using brew. Mind the version.


export ANDROID_SDK_ROOT='/usr/local/Cellar/android-sdk/24.4.1_1'



In your case it looks like you should run this:


export ANDROID_SDK_ROOT='/Users/username/Library/Android/sdk'





Error is still the same. Also, I double checked and ANDROID_SDK_ROOT is set in .bash_profile. Even echo $ANDROID_SDK_ROOT gives the correct path: /usr/local/Cellar/android-sdk/24.4.1_1 I'm using macOS with HomeBrew.
– Shivam Maheshwari
Nov 9 '16 at 14:10



ANDROID_SDK_ROOT


.bash_profile


echo $ANDROID_SDK_ROOT


/usr/local/Cellar/android-sdk/24.4.1_1



ok i can run android from cordova, i changed ANDROID_HOME to,


export ANDROID_HOME=/usr/local/opt/android-sdk



You should add AVD Emulator.
Go to this location:


C:Users%username%AppDataLocalAndroidsdk



start AVD Manager and in the second tab(Device Definitions) click on the button "createAVD".



Platfoms directory was missing in /usr/local/share/android-sdk.



I created an empty directory named platforms that fixed the issue.



Check if the system image used by your AVD has been downloaded under $ANDROID_SDK_ROOT/system-images/


$ANDROID_SDK_ROOT/system-images/



In my case it was broken because ANDROID_HOME and ANDROID_SDK_ROOT were different, so once I set ANDROID_HOME to be the same as ANDROID_SDK_ROOT then it started working.





That worked for me too, thanks
– Pablo Carpio
Apr 17 at 16:37



Oleg Cherrs answer led me to a solution. As he mentioned



Go to /.android/avd/ and open config.ini. Find the >image.sysdir.1 property. It points at the directory inside SDK containing system >images. Make sure that this directory exists and contains files like build.prop, >system.img, etc. If it doesn't, then you have to open the SDK Manager and >download system images your AVD requires (see below).



I found the corresponding emulator *.ini file in the avd directory.
There I modified the "image.sysdir.1" entry. I replaced the relative with an absolute path (append the ANDROID_SDK_ROOT in front). After that the emulator started from the command line as expected.



I had the same issue which after setting following path variables got vanished
Note AVD Home path is different from other three.



enter image description here



Just ran into that issue today and managed to solve it.



Emulator: [140735565005632]:ERROR:android/android-emu/android/qt/qt_setup.cpp:28:Qt library not found at /Users/your_user_name/Library/Android/sdk/emulator/lib64/qt/lib



15:08 Emulator: Could not launch '/Users/your_user_name/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-x86_64': No such file or directory



The solution was pretty simple. Just install Android emulator through Android Studio => tools => Android => SDK manager => SDK tools => select Android Emulator => Apply



I'm using a MacBook Pro on macOS High Sierra, and I believe your machine has nothing to do with this issue. The emulator is not obviously installed when running the Android Studio installation manager for the first time, at least for me, with Android Studio 3.0.1



Also make sure you have your paths defined in your .bashrc or .zshrc like this:


export ANDROID_HOME=/Users/your_user_name/Library/Android/sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools



To solve this problem I had to install the package with the missing system image using SDK Manager.exe (in "C:Program Files (x86)Androidandroid-sdk"). I had noticed that the system image I needed ("android-23") was missing in "C:Program Files (x86)Androidandroid-sdksystem-images".



After running SDK Manager.exe and installing the appropriate packages I could run the emulator in Android Studio.



Here's the solution that worked for me:



https://www.embarcadero.com/starthere/xe5/mobdevsetup/android/en/creating_an_android_emulator.html



After quite some time trying other Googled "solutions", the only thing that worked for me, after setting the ANDROID_SDK_ROOT environment variable on Windows, and also adding and removing ANDROID_HOME and ANDROID_SDK_HOME variables, was Xerox23's answer - editing the AVD's config.ini to hardcode the value of ANDROID_SDK_ROOT into the image.sysdir.1 property.



This was using Android Studio 3.0.1 and emulator 26.1.4, launching the virtual device from the AVD Manager from within Android Studio.



For windows machine: After trying alot of set path, remove path and etc.
What finally work is to located the folder C:Usersjohndoe.android and delete it. after that you can lunch your Android Studio, it will ask you to download and install a new AVD and it will override and create a fresh new folder and files. This solve the problem.


C:Usersjohndoe.android



As @EFreak did I installed the android-sdk with homebrew. I needed to do this, because I was following the nativescript tutorials. If you like me intend to use the brew version over the android-sdk version use this answer (this will allow you to use nativescripts tns run android api), and if you want the android studio default android-sdk follow @EFreak's answer.


tns run android



Basically you just need to change your Android SDK location in Android studio. First open a project in android studio. Then open the SDK Manager by clicking this button.



android sdk manager button location



Next when the default preferences for the android SDK manager comes up you need to click edit next to the android SDK location.



enter image description here



Next you need to actually update the sdk location on the sdk components setup screen my brew android-sdk was located here /usr/local/share/android-sdk.


brew


/usr/local/share/android-sdk



enter image description here



Then just finish up the wizard by installing whatever packages. I needed to delete and recreate my device emulators at this step, but it seemed to work great after that.





This unfortunately didn't work out for me :(
– Stephen Tetreault
Jun 6 at 14:02



I ran into this problem since I've been doing React Native since the early days. Google has deprecated the commandline tools and insists on Android studio. The solution for me was to remove the commandline tools



rm -rf /usr/local/Cellar/android-sdk


rm -rf /usr/local/Cellar/android-sdk



rm /usr/local/bin/android


rm /usr/local/bin/android



open up AS install sdk v6 as instructed https://facebook.github.io/react-native/docs/getting-started.html#1-install-android-studio



make a new AVD and it'll launch without error



I just had the same problem on Mac and here's what I did:



I had the same problem. I deleted the image emulator on the .android/avd folder and after I installed the lib32stdc++6:


sudo apt-get install lib32stdc++6



So, it works! Magic?






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard