Afzal Najam
Afzal's Compositions

Afzal's Compositions

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

Afzal Najam's photo
Afzal Najam
·Feb 11, 2022·

3 min read

Update (April 28, 2022): Android and Google TV emulator images of API 31 and Tiramisu are now available for Apple Silicon!

Update (April 4, 2022): Updated emulators for Android 7.x and 8.x (API 24-27) have also been released! This article has been updated to reflect that.

Update (February 21, 2022): Wear OS 3 emulator for Apple Silicon is now available on Android Studio Bumblebee!

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)
  • All Wear OS emulators.* (see update)
  • All Android Automotive emulators.
  • Android 8.1 (API 27) and below.* (see update)

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.

  2. 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.

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

  4. 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
    
  5. Start the service.

     Start-Service sshd
    

    Make it run automatically on startup (optional).

     Set-Service -Name sshd -StartupType 'Automatic'
    
  6. 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."
     }
    
  7. Run the emulator you want to use on the host PC now.

  8. 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
    
  9. Go ahead and connect ADB.

     $ adb connect localhost
    
  10. 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!

 
Share this