Mac M1 Android Emulator
This is the second post that I dedicate to talk about configurations using the new M1 Apple processor. As I said in the previous post, these configurations are workarounds until stable versions are released, however, for me, they have been useful and I guess that someone in the same situation as me can benefit from that.
The emulation software enables ARM64-based Android apps to run on a Mac. Similar to the virtualization of Microsoft’s Windows operating system on Apple’s M1 devices, the native hardware virtualization of the M1 chips via Qemu is also used here. According to Google, however, the presentation is only a first preview version of the emulator. No emulators at this point. IntelliJ has some lags in performance on M1 (because it is not native, and Intel built), but feels pretty usable. Yes, Android Studio and the M1 emulator are working. However keep in mind that sometimes Android Studio will start pushing to Swap massively about 1 hour of work in. On A Mac Book Pro with M1 Chip. Android Emulator and Android SDK tools are downloaded. “The emulator process for AVD Pixel2API30 has terminated.” on.
This is the first preview. This only works on M1 Apple Silicon Macs. It has a lot of rough edges. To use, open the.dmg, drag/drop to /Applications, then right click in /Applications and select Open; skip the developer identity verification check. The first launch may take a while. Files: android-emulator-m1-preview.dmg: Download this file. This is a preview of some basic Android emulation functionality on the M1. There are still many issues, but apps work at a basic level. To be updated soon with more fixes.
Using Android studio in the new Macbook Air
When you install Android Studio you will get the following warning:
Unable to install Intel® HAXM
Your CPU does not support VT-x.
Unfortunately, your computer does not support hardware-accelerated virtualization.
Mac M1 Android Emulator Download
Here are some of your options:
1 - Use a physical device for testing
2 - Develop on a Windows/OSX computer with an Intel processor that supports VT-x and NX
3 - Develop on a Linux computer that supports VT-x or SVM
4 - Use an Android Virtual Device based on an ARM system image
(This is 10x slower than hardware-accelerated virtualization)
Creating Android virtual device
Android virtual device Pixel_3a_API_30_x86 was successfully created
And also in the Android virtual device (AVD) screen you will read the following warning:
If you want to learn more regarding virtualization in processors you can read the following Wikipedia article, the thing is that our M1 processor doesn’t support VT-x, however, we have options to run an Android Virtual Device.
As the previous message was telling us, we have 4 options. The easiest way to proceed is to use a physical device, but what if you haven’t one available at the moment you are developing?
From now on, we will go with the option of using an Android virtual device based on an ARM system image as options 2 and 3 are not possible to execute.
Using the virtual emulator
The only thing that you have to do is to download the last available emulator for Apple silicon processors from Github https://github.com/741g/android-emulator-m1-preview/releases/tag/0.2
Once you have downloaded you have to right-click to the .dmg file and click open to skip the developer verification.
After installing the virtual emulator, we have to open it from the Applications menu.
After opening it you will see Virtual emulator
in Android Studio available to deploy your Android application. Make sure to have Project tools available in Android Studio (View -> Tool Windows -> Project)
After pressing the launch button you will get your Android application running in your ARM virtual emulator :-)
Conclusion
In this post, we have seen that is possible to install Android Studio in Macbook Air M1 and use a virtual device even that your M1 doesn’t support VT-x. You can learn more about this emulator in the following references:
M1 Macbookを使っている方はFlutterの環境構築でAndroidエミュレータが使えなくて焦ったと思います。
私もまだまだ初心者なので色々と拙いですが、よろしくおねがいします。
M1macじゃなければ動くように設定できている前提で進めます。
(面倒だったら挫折する前にiOSで開発を進めちゃうのでも全然良いと思います。)
M1 Macbookではエミュレータが使えないということで、2020年の12月頃にGoogleがAndroidのデモ操作をできるパッケージを提供しました。
そのパッケージを使うことでAndroid Emulatorというアプリをダウンロードして起動してデモ操作ができるようになりました。
そして2021年3月頃に、そのパッケージは必要なくなりました。Android Studioでエミュレータが起動できるようになったからです。
その方法を解説します。
まず画面右上の辺りからAVD Managerを開き、 Create Virtual Device...を開きます。
適当に選択します。
次にOther Imagesの欄に移動してください。
私は既にダウンロード済みになっていますが、 API Level30辺りを適当に選択して、ください。
大事なのはABIがarm~となっているやつです。このarmがついているのを選択するとM1でも利用できるようになるみたいです。(まだまだ作業は続きます)
Nextを押してダウンロードを進めていってください。
ダウンロードが完了して開こうとすると、The emulator process for AVD was killed と出てエミュレータは開けないでしょう。
ここで一度API Levelがダウンロードしたエミュレータと同じものを利用できるようになっているかチェックしてみてください。
次に、
./Library/Android/sdk/emulator/darwin-aarch64-replace.sh
のdarwin-aarch64-replace.shを起動してください。
起動の仕方はTerminalでemulatorディレクトリまで移動した後に、
これで
emulator-darwin-aarch64-0.2.zip
がダウンロードされているはずです。このファイルをクリックすると emulator-darwin-aarch64-0.2
というファイルが生成されます。
emulator-darwin-aarch64-0.2を開いて中身を全てemulatorファイルに移してください。
Mac M1 Android Emulator Free
そしてAVD Managerを開くと
Apple M1 Android Simulator
<参考記事>
https://github.com/google/android-emulator-m1-preview/issues/34