Nerd For Tech
Published in

Nerd For Tech

How to downgrade Android Emulator on macOS

The Issue

After recently upgrading Android Studio to 4.1.3, I ran into an issue when trying to launch an Android Virtual Device. The error message read: AVD Manager — The emulator process for AVD Pixel_2_API_29 was killed.

The AVD had worked perfectly fine while testing a React Native project a day earlier, so I knew that the upgrade was most likely the reason for the error. In this post I’ll go through the steps I took to troubleshoot the problem, and provide the solution that I found which involves downgrading Android Emulator back to a previous version.

Troubleshooting

The first thing I tried was to create a new AVD using the same settings as the previous one that worked the day before. I tried this using API 29 and 30 to see if it maybe related to the API version, but this didn’t fix the error.

After searching for solutions on Stack Overflow and other forums, I came across a post that recommended setting the graphics mode to software instead of automatic/hardware. While this seems to work for some people, it didn’t work for me.

Another user had explained that uninstalling and then reinstalling Intel x86 Emulator Accelerator (HAXM Installer) in the SDK Tools menu had resolved their issue, but unfortunately this didn’t work for me either.

Getting closer to a solution…

The final debugging step I took was to try and manually start the emulator from the command line. I used this command list the names of each AVD and make sure the emulator had access to them in the first place.

emulator -list-avds

Once I got the returned list of emulators, I tried running one them.

emulator -avd Pixel_2_API_29

This gave me a new error which was a bit more descriptive at least. It read:

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

After some more searching using this new error, I found a post explaining that Apple had introduced IOUSBHost in macOS 10.15 and it looked like the best fix was simply to downgrade to an older version of Android Emulator which does not require this framework, at least until I can upgrade my OS.

After a lot of hunting for ways to downgrade, I came across this post which explained the downgrading process. It was difficult to find the right url for the legacy version of android emulator I was trying to install, but after some searching I found the URL for the previous stable release 3.4.5.

I’ve outlined the steps to download and downgrade Android Emulator below.

The Solution

You’ll find the URL for Android Emulator 3.4.5 here: https://dl.google.com/android/repository/emulator-darwin_x64-7140946.zip

Once this file is downloaded, unzip it and you should see the following contents.

The location of the emulator folder currently installed on your machine should be at:

~/Library/Android/sdk/emulator

However you can type the following into your terminal to double check where yours might be installed:

which emulator

The next step is to replace the files of the currently installed emulator folder with the files from the downloaded emulator folder. I recommend making a backup of the currently installed emulator just in case you need to quickly revert your changes.

I did this with a simple copy and paste, where I was able to overwrite any files that matched by name. This is important because you will actually want to leave the package.xml file in place in the currently installed emulator folder. This file will essentially trick Android Studio into thinking you have the latest version installed.

If you don’t leave this file in place, you won’t be able to launch your AVD using the Android Studio UI, instead it will try and automatically upgrade you to the same version that is causing the error in the first place. However you can technically still launch an AVD without the package.xml file being present by using the command line to run your emulator, but that isn’t ideal.

Once you’ve done this, you should be able to successfully launch your AVD again! If you check the SDK Tools menu in Android Studio at this point it will still think you have the latest version of Android Emulator installed though, in my case it was 3.5.3. To avoid this being an issue I was able to edit the revision tag on line 141 of the package.xml file to read:

<revision><major>30</major><minor>4</minor><micro>5</micro></revision>

This error was a pain to figure out but I hope that these steps can help anyone who is having similar issues. If anyone has found another fix let me know!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Arthur Wilton

Arthur Wilton

41 Followers

Software Developer and Video/Post Production Professional. Recent graduate of Flatiron School.