54

I have upgraded the mac OS to Big Sur and none of the emulators are working. It seems that all Android emulators Fails on Mac OS Big Sur Beta. I deleted the old emulators and created new ones with different HW/SW, unsuccessfully. Introduced the following issues in the android emulator.

  1. ffffffffb69b4dbb: unhandled exit 1d
  2. Emulator Engine Failed
  3. adb Device Offline

https://issuetracker.google.com/issues/165038831

Does anyone have a solution?

EDIT 27.04.2021

~/Library/Android/sdk/emulator/emulator -gpu host -read-only -feature HVF -avd Pixel_4_API_29
emulator: Android emulator version 30.5.5.0 (build_id 7285888) (CL:N/A)
handleCpuAcceleration: feature check for hvf
cannot add library /Users/dunatv/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed
added library /Users/dunatv/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib
cannot add library /Users/dunatv/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libMoltenVK.dylib: failed
HVF error: HV_ERROR
qemu-system-x86_64: failed to initialize HVF: Invalid argument
HAX is working and emulator runs in fast virt mode.
qemu-system-x86_64: Back to HAX accelerator
added library /Users/dunatv/Library/Android/sdk/emulator/lib64/vulkan/libMoltenVK.dylib
emulator: INFO: GrpcServices.cpp:301: Started GRPC server at 127.0.0.1:8554, security: Local

UPDATE: 11 Aug 2021

Currently the Emulators and Arctic Fox are working. Tested on Big Sur 11.5.1

Duna
  • 1,564
  • 1
  • 16
  • 36
  • There's another ticket also: https://issuetracker.google.com/issues/166155540. I'm sure one will get merged into the other eventually. – Joe Aug 26 '20 at 17:20
  • I am in the same boat. Pretty much all my testing time goes to trying to boot into simulator. – Tarvo Mäesepp Aug 28 '20 at 09:31
  • 1
    I think this question is related: https://stackoverflow.com/questions/63148352/emulator-does-not-start-c066d201-unhandled-exit-1d It didn't work for me, but maybe can help someone else – Erick M. Sprengel Aug 31 '20 at 00:30
  • 1
    Because there are some solutions that worked for other users. Maybe it can help someone here too. I shared this question there too for the same reason – Erick M. Sprengel Sep 03 '20 at 22:56
  • The issue was fixed by G Team on emulator side. It looks like it should be released in the emulator 30.1.5 – Duna Sep 26 '20 at 05:14
  • It seems with todays update macOS 11.3 emulators are not working at all – Duna Apr 27 '21 at 11:42
  • The same is happening to me @Duna – Rares Serban Apr 27 '21 at 15:25
  • I've raised a bug for it: https://issuetracker.google.com/issues/186436367 – mieszk3 Apr 27 '21 at 17:20
  • Updated 28-4-2021 Laalto [Solved it here !](https://stackoverflow.com/questions/67288329/android-device-manager-fails-to-launch-after-updating-to-macos-big-sur-11-3/67288845) https://stackoverflow.com/questions/67288329/android-device-manager-fails-to-launch-after-updating-to-macos-big-sur-11-3/67288845 – DouggyC Apr 28 '21 at 07:50
  • **Updated 28-4-2021** [Laalto Solved it!](https://stackoverflow.com/questions/67288329/android-device-manager-fails-to-launch-after-updating-to-macos-big-sur-11-3/67288845) https://stackoverflow.com/questions/67288329/android-device-manager-fails-to-launch-after-updating-to-macos-big-sur-11-3/67288845 – DouggyC Apr 28 '21 at 07:52
  • I am also facing this issue. – manish jain Apr 28 '21 at 11:40
  • It has been fixed in version 30.5.6 of Emulator! The update is there. – mieszk3 Apr 29 '21 at 06:16
  • codesign -s - --entitlements entitlements.xml --force /usr/local/bin/qemu-system-x86_64 - needs to be executed – Duna Apr 29 '21 at 08:30
  • please see the below link. https://stackoverflow.com/a/67316044/2556044, it will help you. – manish jain Apr 29 '21 at 11:02
  • The new update 30.5.6 of the android emulator has solved this problem. Hooray!!! Still on cannary channel – Duna May 01 '21 at 09:21
  • Solved : Check out this [answer](https://stackoverflow.com/a/67380028/8726579) – Rishabh Saxena May 04 '21 at 06:52
  • I can confirm that with today's update for emulators, they are no more working on Catalina too 10.15.7 – Duna Jun 24 '21 at 10:02

14 Answers14

40

Update: this should now be fixed by version 30.5.6 of the Android emulator in the stable channel.

However, if you are now experiencing issues after updating to the latest version of the Android Emulator you can fix this by removing and then adding back the Android Emulator from the SDK Manager.

Tools > SDK Manager > SDK Tools
Uncheck Android Emulator and hit apply.
Check Android Emulator and hit apply.


Original answer:

This worked for me https://www.arthurkoziel.com/qemu-on-macos-big-sur

Essentially, create an XML file called entitlements.xml with the following contents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.hypervisor</key>
    <true/>
</dict>
</plist>

Copy the XML file to ~/Library/Android/sdk/emulator/qemu/darwin-x86_64

Then run the following commands in terminal:

codesign -s - --entitlements entitlements.xml --force qemu-system-aarch64
codesign -s - --entitlements entitlements.xml --force qemu-system-aarch64-headless 
codesign -s - --entitlements entitlements.xml --force qemu-system-armel
codesign -s - --entitlements entitlements.xml --force qemu-system-armel-headless 
codesign -s - --entitlements entitlements.xml --force qemu-system-i386
codesign -s - --entitlements entitlements.xml --force qemu-system-i386-headless 
codesign -s - --entitlements entitlements.xml --force qemu-system-x86_64
codesign -s - --entitlements entitlements.xml --force qemu-system-x86_64-headless 
Markymark
  • 2,804
  • 1
  • 32
  • 37
18

Update, 10-1-2020

The Android Emulator team has pushed 30.1.5 which fixes this issue in stable. The dev build, 30.2.0 does not contain this fix. It should be available "soon" according to the Googler's working on this.

Another note, if you experience poor performance in your emulator you may wish to try using the host's GPU for rendering. This can be accomplished by running the following command in your terminal where -avd is the name of your emulator device with spaces turned to underscores.

~/Library/Android/sdk/emulator/emulator -gpu host -feature HVF -avd pixel_3a_api_29

Old information, kept for educational value:

This is the reference to the commit fixing this issue for Big Sur. This looks like it should be released in the emulator 30.1.5 (see log https://android.googlesource.com/platform/external/qemu/+log/refs/heads/emu-30-release) which should be in the next canary build.

If you can't wait, you should be able to build off that branch. Lightly tested guide heavily pulling from the readme of the repo:

# Get the google repo tool - you can skip if you already have it
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > /usr/local/bin/repo && chmod +x /usr/local/bin/repo

# Get the code, will take some time. Probably best to go get a coffee here or run on a server if you have poor internet
mkdir -p $HOME/emu-master-dev && cd $HOME/emu-master-dev
repo init -u https://android.googlesource.com/platform/manifest -b emu-master-dev
repo sync -j8

# Get XCode 10.1 - required
https://download.developer.apple.com/Developer_Tools/Xcode_10.1/Xcode_10.1.xip
sudo xcodebuild -license accept &&
sudo xcode-select --install

# Get MacOS 10.13 SDK which is required
export XCODE_PATH=$(xcode-select -print-path 2>/dev/null)
git clone https://github.com/phracker/MacOSX-SDKs
cp -r MacOSX-SDKs/MacOSX10.13.sdk/ "$XCODE_PATH/Platforms/MacOSX.platform/Developer/SDKs"

# Build the emulator, which will be another coffee break...
cd external/qemu && android/rebuild.sh

# run it :)
./objs/emulator -list-avds
Simon Sickle
  • 204
  • 1
  • 5
  • 10
    It seems with todays update macOS 11.3 emulators are not working at all – Duna Apr 27 '21 at 11:43
  • 2
    Not working on 11.3. Tried from AVD tool, from command line, in tool window of AS. Nothing worked on this BigSur version. As a work around latest version of Genymotion works. – Ionut Negru Apr 27 '21 at 16:42
  • 3
    For macOS Big Sur 11.3, [this](https://stackoverflow.com/questions/67288329/android-device-manager-fails-to-launch-after-updating-to-macos-big-sur-11-3/67288845) post has a solution that worked for me. I'm putting it here for reference. – Abhilash G Apr 28 '21 at 04:51
  • 2
    The new update 30.5.6 of the android emulator has solved this problem. Hooray!!! – Duna May 01 '21 at 09:22
  • Error happening for MacOs Big Sur 11.4 and this does the work –  Jun 11 '21 at 13:33
15

Steps to fix the issue:

1.Open Terminal and go to the directory /Users/<username>/Library/Android/sdk/emulator/qemu/darwin-x86_64/

2.Create an xml file named entitlements.xml with touch or cat commands

3.Add this content to the entitlements.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>com.apple.security.hypervisor</key>
    <true/>
  </dict>
</plist>

4.Then simply sign the qemu-system-x86_64 with it:

codesign -s - --entitlements entitlements.xml --force qemu-system-x86_64

5.Now simply restart Android Studio and the Android Emulator should work again!

Burak Demirezen
  • 545
  • 6
  • 12
5

My solution is wiping data from Android studio AVD, then start it again and again until it is successfully launched, using ./emulator @Pixel_3a_API_29 command.

Eric
  • 51
  • 1
2

After trying many of the answers / comments on SO, found this workaround to work and be reproducible:

  1. Setup a new AVD

I used Pixel 3 & 3a, API 30, default options

  1. Launch the AVD using the emulator CLI
$ ~/Library/Android/sdk/emulator/emulator @Pixel_3a_API_30

You'll see the infamous ...unhandled exit 1d

  1. Cancel the command with ⌃ + c or press the x on the emulator sidebar

You should see a spinner about Saving State...

  1. Run the emulator again (step 2), this time it should show:
    Screenshot of the top of an Android emulator with a dialog, reading "Resetting for cold-boot: emulator engine failed"

5. Click DISMISS (or wait) and the emulator should boot into Android

Note: Starting the same AVD from Android Studio / AVD Manager GUI will still run into this exception, so when you need it - start the emulator like in step 2.

Shazbot
  • 1,444
  • 1
  • 11
  • 21
2

Spent a whole day trying out different methods, including downloading qemu. Finally...went into Android SDK> SDK tools > updated everything, made sure HAXM installer is installed and ticked. Worked!

pierrot
  • 21
  • 1
1

Running the emulator like this:

~/Library/Android/sdk/emulator/emulator -wipe-data @Pixel_3a_API_30

Fixed it for me.

1

As mentionned by @Demirezen, for the time being, it is a code signing issue see details here. Either code signing by yourself or using emulator 30.6.4 from canary build solves the problem.

GaD
  • 11
  • 1
1
  1. Go to /Users/<your user>/Library/Android/sdk/emulator/qemu/
  2. Inside this file you will see files. If the names of those files contain the number 64 then:
  3. Create virtual device with image arm64-v8a + API LEVEL= S

After those steps emulator should be opened.

0

After last BigSur beta update (11.0 Beta (20A5395g)), Android Studio keeps shuting down. UI is not responding if I open any subwindow...

Never more beta

murt
  • 3,790
  • 4
  • 37
  • 48
0

Seems to work with emulator 30.2.6 (latest in beta channel at this moment) Although there was a problem with a lockfile that prevented the emu from launching.

Here's what brought everything back to normal:

  1. Wiping data of all AVDs (not sure if this is required)
  2. Looking through every ~/.android/avd/*.avd/ folder and removing the hardware-qemu.ini.lock file if present.
Ivan Bartsov
  • 19,664
  • 7
  • 61
  • 59
0

invalidate caches / restart and re-create the image, seems like some behind-the-curtains configuration is not forward-compatible.

CptEric
  • 897
  • 9
  • 23
0

I had the same problem, just update your android studio and all your sdk tools to the latest version and everything will work just fine.

0

Adding proper ANDROID_AVD_HOME helps somehow. You can add export ANDROID_AVD_HOME=$HOME/.android/avd to ~/.bash_profile