How can I launch Android Emulator without android studio on Mac M1
Asked Answered
D

4

15

I'm trying to start the emulator with this command emulator -avd Pixel_4_API_30 but it gives me an error:

[8633370112]:ERROR:android/android-emu/android/qt/qt_setup.cpp:28:Qt library not found at ../emulator/lib64/qt/lib
Could not launch '/Users/primulax/../emulator/qemu/darwin-x86_64/qemu-system-aarch64': No such file or directory

Android Studio specs:

Build #AI-203.7717.56.2031.7935034, built on November 21, 2021
Runtime version: 11.0.10+0-b96-7249189 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.2
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 8
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: org.jetbrains.kotlin

✅ I was able to run with ~/Library/Android/sdk/emulator/emulator -avd Pixel_4_API_30 with this command

Diadelphous answered 7/2, 2022 at 8:41 Comment(2)
So, do you want to run an Android emulator without having Android Studio installed at all or just without having it running?Dynamic
no, I have Android Studio installed but I don't want to launch it every when I just need emulator.Diadelphous
G
12

I just experienced the same issue on a freshly setup machine, emulator installed through SDK manager and all.

The error message says it all actually: If you go to /Users/primulax/../emulator/qemu/ on your machine, you'll notice that of course there is no darwin-x86_64 directory, but darwin_aarch64, since you are on an M1 machine. Whatever the reason is the emulator looks in the wrong directory, if you just duplicate the darwin_aarch64 folder and name your copy darwin-x86_64, it works as intended. Not ideal, but it's a workaround until this path-problem is fixed.

Edit: Please take a look at @Andrew Stromme's comment. Of course symlinking is a much more elegant solution to this problem!

Ginnie answered 17/3, 2022 at 8:33 Comment(3)
yes, it's kinda bug I guess so.Diadelphous
Great answer but please edit it. The directory name is darwin-aarch64, not darwin_arch64 or darwin_aarch64 . I accidentally corrupted the emulator by replacing the wrong name, and it made me reinstall emulator sdk.Ahwaz
I symlinked it with ln -s darwin-aarch64 darwin-x86_64 which worked and seems cleaner than copying the contents of the directory. I also had to run it from my tools directory ~/Library/Android/sdk/tools.Diann
U
33

Use ~/Library/Android/sdk/emulator/emulator instead of ~/Library/Android/sdk/tools/emulator on MacOS, for Ubuntu use ~/Android/Sdk/emulator/emulator.

Upstate answered 25/8, 2022 at 10:11 Comment(2)
~/Library/Android/sdk/emulator/emulator -avd Pixel_5_API_33 -netdelay none -netspeed fullTamah
works for me as well. ensure to call it using either full path or cd and use ./emulator instead. in my case, the emulator command already linked on sdk/tools/emulatorBrendanbrenden
G
12

I just experienced the same issue on a freshly setup machine, emulator installed through SDK manager and all.

The error message says it all actually: If you go to /Users/primulax/../emulator/qemu/ on your machine, you'll notice that of course there is no darwin-x86_64 directory, but darwin_aarch64, since you are on an M1 machine. Whatever the reason is the emulator looks in the wrong directory, if you just duplicate the darwin_aarch64 folder and name your copy darwin-x86_64, it works as intended. Not ideal, but it's a workaround until this path-problem is fixed.

Edit: Please take a look at @Andrew Stromme's comment. Of course symlinking is a much more elegant solution to this problem!

Ginnie answered 17/3, 2022 at 8:33 Comment(3)
yes, it's kinda bug I guess so.Diadelphous
Great answer but please edit it. The directory name is darwin-aarch64, not darwin_arch64 or darwin_aarch64 . I accidentally corrupted the emulator by replacing the wrong name, and it made me reinstall emulator sdk.Ahwaz
I symlinked it with ln -s darwin-aarch64 darwin-x86_64 which worked and seems cleaner than copying the contents of the directory. I also had to run it from my tools directory ~/Library/Android/sdk/tools.Diann
D
4

If you have Android Studio installed, you can run the emulator from terminal without having started Android Studio first.

First of all, run

cd ~/Android/Sdk/tools && ./emulator -list-avds

to get a list of all the available Android virtual devices that you have installed.

Then, copy the name of the virtual device you want to use and run

cd ~/Android/Sdk/tools && ./emulator -avd YOUR_DEVICE_NAME

where you replace "YOUR_DEVICE_NAME" with the name of a virtual device that was listed in the installed virtual devices list.

This info and more that you may find useful can be found in the official documentation.

Now for the error you get it's most possibly due to a wrong file path. It seems that others have also faced this issue and a bug has been opened before here. The most common solution proposed is to launch emulator from the

/path/to/android-sdk/tools

directory in command line.

Also, before trying this or any other solution listed in this issue tracker, firstly make sure that you have installed from the SDK Manager the Android Emulator in SDK Tools.

Android Emulator in SDK Manager

Dynamic answered 7/2, 2022 at 12:12 Comment(0)
F
2
cd  $ANDROID_HOME/emulator;
 ./emulator -avd Pixel_6_Pro_API_33

works for me in recent versions. darwin-aarch64 already exists in emulator/qemu .

Flee answered 26/9, 2023 at 3:11 Comment(1)
using ./ before emulator did the job for me. many thanks!Randallrandan

© 2022 - 2024 — McMap. All rights reserved.