M1 MacでAndroid エミュレータを開く方法 <パッケージ使わない> (Android Studio, Flutter)

M1 Macbookを使っている方はFlutterの環境構築でAndroidエミュレータが使えなくて焦ったと思います。
私もまだまだ初心者なので色々と拙いですが、よろしくおねがいします。

M1macじゃなければ動くように設定できている前提で進めます。

(面倒だったら挫折する前にiOSで開発を進めちゃうのでも全然良いと思います。)

M1 Macbookではエミュレータが使えないということで、2020年の12月頃にGoogleがAndroidのデモ操作をできるパッケージを提供しました。

そのパッケージを使うことでAndroid Emulatorというアプリをダウンロードして起動してデモ操作ができるようになりました。

そして2021年3月頃に、そのパッケージは必要なくなりました。Android Studioでエミュレータが起動できるようになったからです。

その方法を解説します。

まず画面右上の辺りからAVD Managerを開き、 Create Virtual Device...を開きます。

![スクリーンショット 2021-04-04 20.59.19.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1007371/8512ad3f-03c7-037a-912c-da856737969b.png)

適当に選択します。　![スクリーンショット 2021-04-04 21.03.50.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1007371/6688ff7e-3501-83d0-3dcc-03451c2cbe27.png)

次にOther Imagesの欄に移動してください。
私は既にダウンロード済みになっていますが、 API Level30辺りを適当に選択して、ください。
大事なのはABIがarm~となっているやつです。このarmがついているのを選択するとM1でも利用できるようになるみたいです。(まだまだ作業は続きます)
Nextを押してダウンロードを進めていってください。
![スクリーンショット 2021-04-04 21.03.50（2）.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1007371/3fab6718-c0db-52ba-ee8e-fbf52dba21be.png)

ダウンロードが完了して開こうとすると、The emulator process for AVD was killed　と出てエミュレータは開けないでしょう。
![スクリーンショット 2021-04-04 21.08.48.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1007371/7aa78a43-8d8d-2d54-3b52-1cd48dc42094.png)


ここで一度API Levelがダウンロードしたエミュレータと同じものを利用できるようになっているかチェックしてみてください。
![スクリーンショット 2021-04-04 21.10.38.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1007371/b53a7bab-7c04-d901-b17b-b7a34a0d9d07.png)

次に、
```
./Library/Android/sdk/emulator/darwin-aarch64-replace.sh
```
のdarwin-aarch64-replace.shを起動してください。

起動の仕方はTerminalでemulatorディレクトリまで移動した後に、

```
$ ./darwin-aarch64-replace.sh
```

```
ayumu@ayumunomac emulator % ./darwin-aarch64-replace.sh
curl -L https://github.com/google/android-emulator-m1-preview/releases/download/0.2/emulator-darwin-aarch64-0.2-engine-only.zip -o emulator-darwin-aarch64-0.2.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   651  100   651    0     0   2021      0 --:--:-- --:--:-- --:--:--  2021
100 91.8M  100 91.8M    0     0  6882k      0  0:00:13  0:00:13 --:--:-- 9427k
unzip emulator-darwin-aarch64-0.2.zip
Archive:  emulator-darwin-aarch64-0.2.zip
   creating: emulator-darwin-aarch64-0.2/
  inflating: emulator-darwin-aarch64-0.2/NOTICE.csv  
  inflating: emulator-darwin-aarch64-0.2/qsn  
  inflating: emulator-darwin-aarch64-0.2/qemu-img  
   creating: emulator-darwin-aarch64-0.2/lib64/
  inflating: emulator-darwin-aarch64-0.2/lib64/libemugl_common.dylib  
   creating: emulator-darwin-aarch64-0.2/lib64/qt/
   creating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/
   creating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/platforms/
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/platforms/libqcocoa.dylib  
   creating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/styles/
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/styles/libqmacstyle.dylib  
   creating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/bearer/
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/bearer/libqgenericbearer.dylib  
   creating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/iconengines/
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/iconengines/libqsvgicon.dylib  
   creating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/imageformats/
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/imageformats/libqgif.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/imageformats/libqwbmp.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/imageformats/libqwebp.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/imageformats/libqico.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/imageformats/libqmacheif.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/imageformats/libqjpeg.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/imageformats/libqtiff.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/imageformats/libqsvg.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/imageformats/libqicns.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/imageformats/libqtga.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/plugins/imageformats/libqmacjp2.dylib  
   creating: emulator-darwin-aarch64-0.2/lib64/qt/lib/
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/lib/libQt5CoreAndroidEmu.5.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/lib/libQt5PrintSupportAndroidEmu.5.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/lib/libQt5SvgAndroidEmu.5.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/lib/libQt5WidgetsAndroidEmu.5.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/lib/libQt5DBusAndroidEmu.5.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/lib/libQt5GuiAndroidEmu.5.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/qt/lib/libQt5NetworkAndroidEmu.5.dylib  
   creating: emulator-darwin-aarch64-0.2/lib64/gles_swiftshader/
  inflating: emulator-darwin-aarch64-0.2/lib64/gles_swiftshader/libEGL.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/gles_swiftshader/libGLES_CM.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/gles_swiftshader/libGLESv2.dylib  
   creating: emulator-darwin-aarch64-0.2/lib64/vulkan/
  inflating: emulator-darwin-aarch64-0.2/lib64/vulkan/libMoltenVK.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/vulkan/MoltenVK_icd.json  
  inflating: emulator-darwin-aarch64-0.2/lib64/libshadertranslator.dylib  
  inflating: emulator-darwin-aarch64-0.2/lib64/libOpenglRender.dylib  
  inflating: emulator-darwin-aarch64-0.2/LICENSE  
  inflating: emulator-darwin-aarch64-0.2/darwin-aarch64-replace.sh  
   creating: emulator-darwin-aarch64-0.2/resources/
   creating: emulator-darwin-aarch64-0.2/resources/macroPreviews/
  inflating: emulator-darwin-aarch64-0.2/resources/macroPreviews/Reset_position.mp4  
  inflating: emulator-darwin-aarch64-0.2/resources/macroPreviews/Walk_to_image_room.mp4  
  inflating: emulator-darwin-aarch64-0.2/resources/macroPreviews/Track_vertical_plane.mp4  
  inflating: emulator-darwin-aarch64-0.2/resources/macroPreviews/Track_horizontal_plane.mp4  
  inflating: emulator-darwin-aarch64-0.2/resources/Toren1BD_Decor.png  
  inflating: emulator-darwin-aarch64-0.2/resources/poster.png  
  inflating: emulator-darwin-aarch64-0.2/resources/Toren1BD.mtl  
  inflating: emulator-darwin-aarch64-0.2/resources/Toren1BD_Main.png  
  inflating: emulator-darwin-aarch64-0.2/resources/Toren1BD.posters  
  inflating: emulator-darwin-aarch64-0.2/resources/Toren1BD.obj  
   creating: emulator-darwin-aarch64-0.2/resources/macros/
  inflating: emulator-darwin-aarch64-0.2/resources/macros/Track_vertical_plane  
  inflating: emulator-darwin-aarch64-0.2/resources/macros/Reset_position  
  inflating: emulator-darwin-aarch64-0.2/resources/macros/Track_horizontal_plane  
  inflating: emulator-darwin-aarch64-0.2/resources/macros/Walk_to_image_room  
   creating: emulator-darwin-aarch64-0.2/bin64/
  inflating: emulator-darwin-aarch64-0.2/bin64/fsck.ext4  
  inflating: emulator-darwin-aarch64-0.2/bin64/mkfs.ext4  
  inflating: emulator-darwin-aarch64-0.2/bin64/tune2fs  
  inflating: emulator-darwin-aarch64-0.2/bin64/resize2fs  
  inflating: emulator-darwin-aarch64-0.2/bin64/e2fsck  
  inflating: emulator-darwin-aarch64-0.2/source.properties  
  inflating: emulator-darwin-aarch64-0.2/emulator-check  
  inflating: emulator-darwin-aarch64-0.2/NOTICE.txt  
  inflating: emulator-darwin-aarch64-0.2/android-info.txt  
  inflating: emulator-darwin-aarch64-0.2/perfetto-protozero-protoc-plugin  
   creating: emulator-darwin-aarch64-0.2/qemu/
   creating: emulator-darwin-aarch64-0.2/qemu/darwin-aarch64/
  inflating: emulator-darwin-aarch64-0.2/qemu/darwin-aarch64/qemu-system-aarch64  
  inflating: emulator-darwin-aarch64-0.2/qemu/darwin-aarch64/qemu-system-aarch64-headless  
  inflating: emulator-darwin-aarch64-0.2/mksdcard  
   creating: emulator-darwin-aarch64-0.2/lib/
  inflating: emulator-darwin-aarch64-0.2/lib/waterfall.proto  
  inflating: emulator-darwin-aarch64-0.2/lib/emulator_controller.proto  
  inflating: emulator-darwin-aarch64-0.2/lib/advancedFeaturesCanary.ini  
  inflating: emulator-darwin-aarch64-0.2/lib/hardware-properties.ini  
  inflating: emulator-darwin-aarch64-0.2/lib/advancedFeatures.ini  
  inflating: emulator-darwin-aarch64-0.2/lib/hostapd.conf  
   creating: emulator-darwin-aarch64-0.2/lib/pc-bios/
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/efi-e1000.rom  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/kvmvapic.bin  
   creating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/sl  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/pl  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/modifiers  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/sv  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/da  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/no  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/Makefile  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/ja  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/lv  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/it  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/is  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/cz  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/ru  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/en-gb  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/bepo  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/common  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/pt  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/fr-ch  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/fr-ca  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/mk  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/ar  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/hr  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/pt-br  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/hu  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/nl  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/de  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/fi  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/fr  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/es  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/et  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/lt  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/fo  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/en-us  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/de-ch  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/th  
 extracting: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/nl-be  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/fr-be  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/keymaps/tr  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/multiboot.bin  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/vgabios-stdvga.bin  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/bios.bin  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/vgabios-virtio.bin  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/bios-256k.bin  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/linuxboot_dma.bin  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/linuxboot.bin  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/efi-virtio.rom  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/efi-e1000e.rom  
  inflating: emulator-darwin-aarch64-0.2/lib/pc-bios/vgabios-cirrus.bin  
  inflating: emulator-darwin-aarch64-0.2/lib/snapshot_service.proto  
  inflating: emulator-darwin-aarch64-0.2/lib/emu-original-feature-flags.protobuf  
  inflating: emulator-darwin-aarch64-0.2/lib/snapshot.proto  
  inflating: emulator-darwin-aarch64-0.2/lib/ca-bundle.pem  
  inflating: emulator-darwin-aarch64-0.2/lib/ui_controller_service.proto  
  inflating: emulator-darwin-aarch64-0.2/emulator  
rm: ./qemu-img: No such file or directory

```

これで
```
emulator-darwin-aarch64-0.2.zip
```
がダウンロードされているはずです。このファイルをクリックすると　emulator-darwin-aarch64-0.2
というファイルが生成されます。

emulator-darwin-aarch64-0.2を開いて中身を全てemulatorファイルに移してください。

![スクリーンショット 2021-04-04 21.24.17.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1007371/50fb8ac0-2456-5b8a-6f00-71e6f6f78445.png)

そしてAVD Managerを開くと

![スクリーンショット 2021-04-04 21.28.30.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1007371/2cd5eae3-f8f4-7958-62c2-c43fe0da5f5d.png)

＜参考記事＞
https://github.com/google/android-emulator-m1-preview/issues/34