Broken AVD System Path - AVD Manager failed to run Android Emulator

Recently myself got one issue that caused my Android emulator failed to start.

There is a very clear error code: PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value[C:\Program Files (x86)\Android\android-sdk]!

Screenshot as below:

What I have done that cause the issue

In my PC, I have not updated VS and my Android emulator for a while. Before the issue happened, my Android emulator’s API level is 25.

I need to test some features and I thought updating it to API level 27 will be better because nowadays more and more smart phones are built with API level 27.

After updating the properties from AVD manager for this emulator, the issue happened.

Solution

The solution for my issue is actually quite easy.

The only thing you need to do is to make sure that you are using the same System path value for both ANDROID_SDK_ROOT and ANDROID_HOME.

In my case, I set them both to C:\Program Files (x86)\Android\android-sdk which is the default path if you install Android SDK from VS2017.

Why this issue will happen? And why the 2 System Path are not set to the same? Please check below.

Root Cause Analysis

It took me lots of time to research on this issue, the main reason is that almost all the contents from Google is not quite useful to me.

I have tried the below check points:

  1. I checked the Android SDK path is there and all the folders are correct by the path: C:\Program Files (x86)\Android\android-sdk which is the default path when you install Xamarin.
  2. I checked the system environment that there is one System Path whose variable name is ANDROID_SDK_ROOT.
  3. I checked the AVD path in my PC which is: C:\Users\{UserName}\.android\avd, and the emulator image is there.

Then I found one document looks quite professional here: PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value

But if you look at its answer, it does not help me either because I followed the steps and check all the things.

Finally, there is one comment in that article that caught my eyes.

It said:

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.

Then I suddenly notice the issue’s root cause.

Actually the reason why I am getting this error is that I have 2 copies of Android SDK on my PC. Why? Because I installed both VS2017 to develop Xamarin and Android Studio to develop native Android app.

However, when installing VS2017, it will automatically help you to install the Android SDK to path: C:\Program Files (x86)\Android\android-sdk. But when installing Android Studio, it will help to install the Android SDK to path: C:\Users\{UserName}\AppData\Local\Android\sdk, this is also the previous value for my ANDROID_HOME System Environment path.

Why the previous Android emulator will work?

This is a tricky thing actually. Indeed we should ask, why the current updated Android emulator will not work?

This is because: Under each Android SDK path, it will contains a system-images folder, which stores the system images that you can use for your emulator.

In my PC, the previous ANDROID_HOME path, there are only 2 system images under that folder, which are android-25 and android-26. Check below screenshot:

But my updated Android emulator is set to API level 27 which causes the problem. According to this symptom, we can also know that when trying to run Android emulator, it will still check the SDK from ANDROID_HOME, not only ANDROID_SDK_ROOT path. Because under that path, I have the system image for API Level 27.

Inspirision of the issue

At beginning, I was thinking that it would be better to keep 2 versions of Android SDK because they are installed seperately from VS and Android Studio. I was thinking that if one Android SDK environment is broken, then we can easily switch to the other one.

However, after this issue, I thought I was wrong. There are at least 2 disadvantages for doing so:

  1. If you keep both Android SDK the same setting, such as you installed Android 6.0, 7.1, 8.0 SDKs for both, then it will cost lots of the hardware disk of your PC, which is not worth it.
  2. If you forgot to make them the same, you will get the similar or same issue like me.

In conclusion, the best practice is to only maintain one Android SDK and if there is any issue, try fixing them or reinstall the whole Android SDK.

Xamarin.Android vs. Native Android - How you implement Java Listener in C# Pain points of Xamarin.Forms using Azure Mobile Apps offline sync feature
You need to set install_url to use ShareThis. Please set it in _config.yml.

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×