LoginSignup
40
24

More than 3 years have passed since last update.

M1 MacでAndroidエミュレータを動かす

Last updated at Posted at 2021-01-15

先日M1 Macを購入し、 思ったよりもトラブることなく快適に使っています。

Androidの開発環境を作っていたところ、まだ公式にはエミュレータが使えない状態だったので、何とかできないかと試してみました。

※ この記事内の情報はすべて、執筆時点(2021/01/15)のものです。

Android Studioを入れたての状態だと

M1 Macはまだサポートされていないので……
image.png
AVDマネージャを開くと、「Your CPU does not support VT-x.」と警告されます。
(そもそもVT-xが使えることは無さそうですが。)

image.png
x86用のイメージでエミュレータを開こうとしても、エラーが出て起動できません。

ARM用イメージを試してみる

AVDマネージャからARM用イメージを追加して試してみます。

image.png
「Other Images」に、arm64-v8a用のイメージがありました。
とりあえずこれを使おうとしてみます。

image.png
x86用イメージと同様、エラーが出て起動できませんでした。
arm64版のイメージだからって、そのまま使えるわけではないみたいです。

Android Emulator M1 Previewを試す

google/android-emulator-m1-previewを試してみます。

https://github.com/google/android-emulator-m1-preview

  1. releasesのページから一番新しいのを取得(執筆時点ではInitial Preview 2)
  2. dmgを開いて「Android Emulator」をApplicationsにインストールする
  3. インストールした「Android Emulator」を右クリックから開く ※普通に開くと「開発元を検証できないため開けません」のエラーが出ます

image.png

開きました。:tada:

ADBのパスを通す

しかし、別の警告が出ています。

image.png

警告に書いてある通り、エミュレータの設定画面でADBのパスを指定します。(adbコマンドにパスが通ってれば自動検知されるかも?)
私の環境では、「/Users/<ユーザー名>/Library/Android/sdk/platform-tools」の中にありました。

そして、エミュレータを起動した状態でAndroid Studioを見ると・・・

image.png

「Virtual Device」として検出された!
ビルドしたアプリが動いた!(画面は無しです。)
デバッグ機能も使えた!!

というわけで、M1 Mac上でAndroid Studioからエミュレータが使えるところまで持ってこれました。:tada::tada:

とはいえ……

まだまだプレビュー版で、このエミュレータだけで開発できる状況ではなさそうです。
既知の課題も山盛り。

  • Webview doesn't work in the AOSP version, but works in the Google APIs version preview v3. However, Chrome doesn't work.
  • No device skins
  • Video codecs not working
  • 32 bit ARM apps won't work
  • Graphical glitches in some Vulkan apps
  • Popup on startup about not being able to find the ADB path (ADB will still notice the emulator if you have it installed though)
  • When building, it may be faster to start then cancel the Python triggered build and then reissue ninja -C objs install/strip versus letting the Python triggered build finish.

なんとWebviewも動かない。
正式版が出るまでは、ちゃんと実機も用意して開発するのが良さそうですね。

40
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
40
24