Android Emulator On Macbook M1

Just a couple of days ago the first PREVIEW version of the Android Emulator for Apple M1 (Apple Silicon) Chips were released. I downloaded the latest. Android Emulator. According to the Android Studio team, the Android Emulator works with API 30 and API S Developer Preview emulator system images. The M1 MacBook beat Intel MacBook in every round, it has faster build time, the temperature is way cooler. But in software development, reliability plays a crucial part too.

  1. Android Emulator On Apple M1
  2. Android Emulator Apple M1 Github
March 14, 2021☕️15 min read🔖#tools

Updated on: August 28, 2021

Note: This article was updated in August 2021. The Macbook Pro M1 I was using crashed and stopped working without any reason on August 25, 2021. In just seven months of use.

It took time to get it repaired. That forced me to buy another laptop. While setting up the new laptop, I thought it is an excellent time to update this post.

Android Emulator On Apple M1


lol @apple started shipping used/damaged products to India by boxing them as NEW?
cc: @AppleSupportpic.twitter.com/hmgZwiS5Kl

— Aman Mittal ⚛️☕🖖🥑 (@amanhimself) August 26, 2021
Android studio emulator on apple m1

I recently upgraded from Macbook Air 2017 to Macbook Pro with an M1 chip. My four-year-old Macbook Air was giving up. The performance to run heavy tasks like using the iOS simulator when developing and working on React Native apps was declining. I had long given up using the Android emulator and used an actual Android device for testing. December 2020 was the time I decided its time to upgrade.

I had a long internal discussion with myself for almost a month about whether I should upgrade to M1 or stick with Intel-based chips and spend them bucks. Don't get me wrong here, M1 is not cheap either as I did go for a RAM upgrade to max limits, which is currently 16GB in the base model.

After going through some online reviews and research, the kind of performance I was expecting has been worth it so far (it is fast, no doubt). I received it two weeks back when writing this post, and since then, I have installed all the necessary tools and utilities that help me work on Web development and React Native apps.

My local environment currently includes:

  • Homebrew (now supported Apple Silicon machines since 2.6.0)
  • Git
  • Node.js
  • npm
  • Zsh
  • Oh My Zsh
  • iTerm
  • Xcode
  • yarn
  • VSCode
  • Rosetta 2

OS apps:

  • Brave
  • Android Studio
  • Insomnia as REST API client
  • Xcode
  • Slack or Discord (for work and community)
  • There (to track team mate's timezone)
  • LICEcap (for gifs)
  • Zoom (for work)
  • GitHub Desktop App
  • Cleanshot (for screenshots)
  • Google Chrome
    • set to default
      • First things to do:
        • Log in to: Gmail, Twitter, GitHub, Outlook
        • Developer mode on
      • Extensions:
        • Grammarly
        • Toby to organize tabs

System Settings:

  • Disable Ask Siri
  • Disable Spotlight search except Applications, Calculator, Definition, and System Preferences.
  • Trackpad:
    • Fix direction: Scroll & Zoom > Natural off
    • Right click: Point & Click > Secondary Click
    • Disable dictionary lookup: Point & Click > Look up & data detectors off
    • More gestures > Swipe between pages off & App Exposé off
  • Finder settings:
    • Preferences > Advanced > Show filename extensions
    • Enable show path bar: View > Show Path Bar
  • Dock:
    • Turn auto hiding on

Copy dotfiles

iTerm

My favorite terminal app that I have been using for years is iTerm. I am currently using two versions of iTerm on my setup. One with Rosetta 2 enabled and the default one. This way, I can only use the Rosetta 2 emulator when required. There are no performance issues I have found with using iTerm with Rosetta 2 for ARM-based applications.

If you'd like a similar setup, go to the Applications folder in your Macbook and duplicate the iTerm application.

You can rename the duplicated iTerm app. I have renamed it to iTerm_rosetta to differentiate between the two. Right-click the duplicated app and click Get Info. In the General, check the box where it says Open using Rosetta.

Now, if you open the second terminal, it will be using Rosetta 2 emulator by default.

Other iTerm profile settings that I use:

Recently I started using Jetbrains Mono font.

For the overall looks and appearance, I use Dracula Pro Color Presets created by Zen Rocha.

And my last favorite thing is to split the working directory into two more different tabs using Command + D for horizontal panes.

Make sure to have the following setting configured from

General > Working Directory > select Advanced Configuration > click button Edit... > select Reuse previous session's directory under Working Directory for New Split Panes.

For terminal prompt, I use Spaceship ZSH.

Homebrew

On December 1, 2020, the Homebrew team announced on their website about the version release 2.6.0. The most significant changes among others they listed were the support for macOS Big Sur, using brew commands instead of brew cask and beginning to support macOS M1 and Apple Silicon or ARM-based chips.

Using the terminal, you can install the Homebrew by executing the default command:

brew installs:

Android Emulator Apple M1 Github

  • node/npm
  • scrcpy (control Android devices connect via USB on mac)
  • adoptopenjdk8 (required for React Native)
  • Karabiner-Elements (remapping function keys)
  • watchman (required for React Native)

What is Karabiner-Elements?

When I bought Macbook Air M1, it had function keys (that got me excited), but I don't understand why Apple decided to replace function keys that would allow me to control Keyboard Brightness?! And moreover, replace it with 'Do Not Disturb'.

Why? That got me confused 🤷

I found this tool called karabiner Elements that can be installed as a brew formula:

Here are the key mappings I am using now:

Git

I did install Git using brew command:

To authenticate GitHub to be used from the terminal environment, I'd recommend you to check out the official document on creating and accessing personal tokens.

Xcode

After installing Git, for me, the next step is to install Xcode app from Apple's App Store.

Then, install 'command line tools'. It is required by many of the formulae in Homebrew.

After installing it, make sure to open it for the first time, from the menu bar, open Xcode > Preferences > Locations and make sure that Command Line Tools point towards the current Xcode app.

ZSH and Oh My Zsh

ZSH is the default shell in macOS Big Sur. However, I like to use Oh My Zsh to manage the ZSH configuration, plugins, and a theme to prettify the terminal.

To install, run the command below:

After installation, make sure that the file .zshrc is exporting the below path at the top:

The first I like to do after setting up the bare minimum ZSH configuration is to install a plugin called zsh-syntax-highlighting. It provides syntax highlighting for the ZSH shell. Execute the series below commands in the terminal window:

This is my final ZSH configuration in the file ~/.zshrc file:

After installing the syntax highlight plugin, it starts to recognize the commands:

VSCode

VSCode and VS Code Insiders are currently supported on ARM chips (as of March 13, 2021). Download the installer for Insiders edition from here and for VSCode here.

I am still using the same VSCode configuration from my previous setup:

Themes

I usually like to switch between a dark and a light theme.

  • For the dark theme where I spent most of my time, I am was previously using morgan.codes-theme, but now I am using fairyFloss.
    • Other themes I switch between:
      • Quiet Light
  • For file icons, I love Material-Icon-Theme.
  • For terminal prompt, I use Spaceship ZSH.
  • Font: Jetbrains Mono font.

Extensions

I use VSCode editor for both writing code and writing blog posts. Thus, the list of extensions below is the combination of extensions that fulfills both of my purposes.

Global NPM Packages I use

  • gatsby-cli To build and test out my personal blog built with Gatsby.
  • npm-check to check for outdated, incorrect, and unused dependencies.
  • git-watch-log to watch a git repo and recent changes.

For React Native Development

  • install node
  • install Watchman to watch changes in the filesystem using the command: brew install watchman.
  • install following gems:
  • install Java Development Kit using the command: brew install --cask adoptopenjdk/openjdk/adoptopenjdk8.
  • Currently, I am using Arctic Fox Canary that supports Apple's based machines for Android Studio.
  • Then install Android SDK (I do not prefer AVD and use an actual device for testing)
  • scrcpy to display and control Android devices connect via USB on Mac.

⚛️ For more instructions on how to set up a development environment for React Native, please follow the official documentation here.

Rosetta 2

Update: I am not using the Rosetta environment to install anything on the secondary machine since August 2021. That is the reason I've mentioned it at the end of the post.

Rosetta 2 is the lifeline that allows you to run apps designed for Intel-based chips that use x86 architecture on ARM-based chips (in this case M1). This solution is provided by Apple in the form of an emulator and doesn't come pre-installed. You have to install it manually. Fire up the Terminal application that comes pre-installed on the Big Sur and let your first command to execute be:

If you decide not to put the flag --agree-to-license, you will be prompted by Apple's interactive install, and you will have to agree to their terms and license conditions to use it.

Conclusion

That’s the setup I now use for my JavaScript, Node.js, React and React Native. I think it's a good machine. Hopefully, M1 is just the beginning of a new era of powerful computers for daily work use 🤞

🤔 The only thing left for me is to find a way to transfer all laptop swag/stickers from my Macbook Air 2017 to Pro. I miss having them on this one.

isapplesiliconready.com is another helpful link I found to check what is compatible to work on Apple Silicon chips natively or using Rosetta or not optimized at all.

I start using genynotion emulator , and i am able to create custom size device using Device setting , but when it comes to give custom dpi their is drop down box of predefine dpi is their is any way to provide custom DPI value to genymotion other than drop down box?

See also questions close to this topic

Emulator
  • Does my style of coding make the Emulator slow?

    I am working with Android Studio it runs really smooth. After some time of update. The app was really slow at getting data from the backend (testing backend with PostMan still fast) also execute other tasks. I wonder if our style of coding slow down the app. Have you ever experienced this ? Does the bad coding style has a huge effect on Emulator performance. If yes, could you please suggest a good way of coding that allows the app in Android Studio run faster.Thank you so much.

  • Backup a entire android phone and restore to a emulator?

    I want to backup a entire android phone including apps, photos, archives and transfer to a emulator on PC

    Is it possible?

  • Failed to find emulator package - not using Android Studio

    I am trying to build a game on Unity , and i needed the sdk. I'm not seeking to download the whole Android Studio, and that is what I did, the problem resides at using cmd to download 'build-tools' it gives me the error: 'warning: dependent package key emulator not found ', so I tried to use one of the solution suggested here (Error 'Dependent package with key emulator not found' while updating Android SDK and tools)but it won't work, it gives the error: 'failed to find package' emulator' .please any suggestions without using Android Studio.

  • Do you know any platform like genymotion for camera automating test?

    I need a platform for automating test which run several devices together and also let me access to its camera and I set my own pic to its camera from my desktop.I do this by python and Linux command but I had problem. I've used genymotion desktop but its camera doesn't support feeding picture. Do you know any platform good enough as genymotion?

  • Solution for adb server version (41) doesn't match this client (39); killing solution for linux

    I was running GenyMotion for android penetration testing but ADB was not connecting to it. I installed it from 'sudo apt install adb' and it gave me the following error.adb server version (41) doesn't match this client (39); killing...

    I did not find any clear solution but on another blog so I decided to share the solution here. Hope you get benefit from this post.Your ADB doesn't match with the client's adb. In this case you need to first remove it. First Kill Server.

    $ adb kill-serverThen find where the ADB is located. Type:-$ which adbOutput: /usr/bin/adb

    Then remove it using following command.

    $ sudo rm /usr/bin/adb

    Finally to match adb version with the client, we will use client's ADB as default ADB.

    $ ps ax | grep adbMy output:-*salazar@capt:~$ ps ax | grep adb

    14534 ? Ssl 0:00 adb -L tcp:5037 fork-server server --reply-fd 614543 ? Sl 0:00 /usr/share/genymotion/tools/adb -s 192.168.56.103:5555 shell14544 ? S 0:00 /usr/share/genymotion/tools/adb -s 192.168.56.103:5555 logcat -v time14572 pts/0 S+ 0:00 grep --color=auto adb*

    Your path may be /opt/...Goto that path using command

    $ cd /usr/share/genymotion/tools$ lsOutput: salazar@capt:/usr/share/genymotion/tools$ lsaapt adb glewinfo lib64

    Copy it to /usr/bin/$ sudo cp adb /usr/bin/

    Now type$ adb devicesIt should work. If it does, congratulations. Enjoy.If it doesn't work, then check the first line. Your error should be a different one.Thank you.

  • feed an image to android emulator(in genymotion) to mock came

    I'm using genymotion in my app tests and realize it's a part from avd and it just use adb.I found we can append to file ~/Android/Sdk/emulator/resources/Toren1BD.postersand feed an image to our emulator camera but it doesn't work for genymotion devices! What should I do?! Do you have any idea?!