How to use Android's x86 emulators on M1 Macs

How to use Android's x86 emulators on M1 Macs

Leveraging another PC for unsupported Android emulators

  • Aug 24, 2022: Android Automotive emulator for API 32 is now available!

  • July 13, 2022: Emulators for Android 5.x and 6.x (API 21-23) have also been released now!

  • April 28, 2022: Android and Google TV emulator for API 31 and 33 are now available for Apple Silicon!

  • April 4, 2022: Emulators for Android 7.x and 8.x (API 24-27) have been released!

  • February 21, 2022: Wear OS 3 emulator for Apple Silicon is now available!

So you bought that shiny new M1 Mac despite reading about some drawbacks for Android development and now you're wondering "how the heck am I gonna run all the emulators that aren't supported on this?"

Well, you've come to the right place! But first, let's see what doesn't work and what to expect in the future. Here are the emulators that cannot run on the Apple silicon as of writing this:

  • All Android TV emulators.* (see update above)

  • All Wear OS emulators.* (see update above)

  • All Android Automotive emulators. * (see update above)

  • Android 8.1 (API 27) and below.* (see update above)

While Android TV emulator images are eventually going to arrive this year, API 23 and lower will never be supported.

What if I told you that you can run and debug them from your new Mac today, granted you have another x64 computer lying around.

For the purpose of this article, we'll call the computer running the emulator, the host PC, and the computer running Android Studio, the guest PC. We will do it on a Windows host but it should work the same way on a Linux or macOS host.

  1. First, enable Remote Desktop on the host PC. It's in the Settings app on Windows 10 and 11.

Remote Desktop setting on Windows 11

If, like me, your host PC needs to be available for other people to use at the same time you need to run the emulator, check out the instructions here on how to allow multiple sessions in Windows 10 and 11.

  1. Install Android Studio on both computers. It's not strictly necessary to do it on the host PC since you can create and run the emulator using command line, but we're just doing it for simplicity.

  2. Download and create the emulator you want on the host PC. For example, I created an Android TV emulator on my Windows machine.

  3. On the host computer, setup an SSH server. On Windows, an easy way is to install OpenSSH server using PowerShell.

     Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
    
  4. Start the service.

     Start-Service sshd
    

    Make it run automatically on startup (optional).

     Set-Service -Name sshd -StartupType 'Automatic'
    
  5. Confirm that the firewall rule is set. It should be created automatically during setup. Run the following to verify:

     if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) {
         Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..."
         New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
     } else {
         Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists."
     }
    
  6. Run the emulator you want to use on the host PC now.

  7. Use ssh to forward port 5555 on the host PC to the guest PC. To do this, run this command where 192.168.2.12 is the IP of the host PC:

     $ ssh -NL 5555:localhost:5555 android@192.168.2.12
    
  8. Go ahead and connect ADB.

     $ adb connect localhost
    
  9. All that's left now is to authorize the computer on the emulator when the dialog popups up.

Android TV emulator showing a debug authorization dialog

If you followed the steps, Android Studio on your guest PC should see the emulator on the host PC. This allows you to run and debug the apps as if the emulator was running locally, circumventing architecture-specific limitations you might face on your M1 Mac.

Big thanks to @goncalossilva for proof-reading and providing feedback for this article!

Did you find this article valuable?

Support Afzal's Compositions by becoming a sponsor. Any amount is appreciated!