Android Studio/Emulator on macOS with ARM CPU M1
Asked Answered
W

21

187

I started Android Studio 4.1 in macOS Big Sure 11.0.1 with new ARM cpu M1

After installing Rosetta: Yes, it builds !

But the Emulator has problems, it shows me CPU does not support VT-x

Even ARM images have this issue enter image description here

I used the most recent, a very old api25 (Google has to do here something) but it's increadible slow

How to make the Emulator work and fast ?

Whipstock answered 19/11, 2020 at 7:28 Comment(9)
Right now you won't be able to run the emulator since it uses Intel HAXM, which in turn uses Intel VT-x and Rosetta doesn't support virtualization. The fix has to come from the Android team to make it work with the M1 way of virtualization. :(Lianeliang
Exactly, I opened a Google ticket as well issuetracker.google.com/issues/173624439 Ok, I understand for x86 but why it's for ARM images as well ?Whipstock
Irrespective of Intel or ARM image, you need virtualization as it acts as a guest OS atop the host OS. The same reason why you can't run an x86 Linux image on a running x86 macOS or x86 Windows without using Parallels or VMWare!Lianeliang
A good read on emulation vs virtualization -- cloudsavvyit.com/7952/…Lianeliang
developer.android.com/studio/releases/… here is a sentence "Support for Apple Silicon is in progress."Whipstock
I hope they release soon as I ended up buying the M1 Mac. :)Lianeliang
Has anyone had success with emulators running API < 29? I'm able to create them but the emulator screen is entirely black.Fermium
@Fermium api25 is complete black on my machine tooWhipstock
@Fermium API 24 is all black for me tooArdy
W
313

Good news !

Edit on 28th of July 2021 🎉 🌈

Apple Silicon M1 Support

Now, there is an arm64 release version available for Android Studio Arctic Fox (2020.3.1) You can download it from here https://developer.android.com/studio#downloads

Easy fix to use right architecture

Tools -> SDK Manager -> SDK Tools (tab) -> Deselect 'Android Emulator' -> Ok

Now, when you try to run your app, or launch device from AVD Manager, it will give the 'Install Emulator' error -> Click Ok. This will automatically download the correct version.

Use an arm64-v8a image !

  • Tools -> SDK Manager
  • Install Android 11 (R) or 12.0 (S) and click Apply
  • Tools -> AVD Manager -> click Create Virtual Device
  • Choose any device that has the Google Play Store icon and click Next
  • Choose an arm64-v8a on "Other Images" tab

Android studio

Whipstock answered 7/12, 2020 at 6:10 Comment(29)
Thanks for the Answer. I have ordered an MBA and just wondering if it will be taxing enough to heat it up and throttle it..Wain
I found a way to hear the ventilator for a long time with 100% CPU usage: just build one of this pull request local github.com/hannesa2/mediapipe/pull/7 With a normal Android studio usage it's max 50 CPU loadWhipstock
You mean it turns on the fan on your new Mac or the old Mac?Wain
On the new one ! But this is the only task which turns it onWhipstock
Got you! So by Android Studio usage you mean also the emulator, right?Wain
Right. Open in Android Studio 5 apps at the same time, sync and build it, uses not more then 50 % This means the bottleneck is somewhere elseWhipstock
cool! thanks. Just wanted to know if the Macbook Air I ordered will have issues with running the emulator for long duration...Wain
I also have a M1 Macbook Pro. I have been using qemu for arm64 on macos for months. It works but the performance really sucks. Why? Because qemu is software-layer emulating without hardware acceleration. But this is what we can have currently with the issue of lagging and unknown bugs. Only if once VM products supported the Apple Virtual Framework, we would experience smoothly.French
My arm64-v8a Emulator is very fast, so qemu is a bad optionWhipstock
It seems your language must be English, otherwise you won't see the arm versionStallion
But , this is not the stable release isn't it? Can you use something like this this on production?Gladiator
@JustCause A lot of stuff is working fast. Current this doesn't work: NDK, kapt (like Room)Whipstock
@hannesach How about the SDK installation? Everything is okay there as usual? Because I'm using Android Studio only for the sake of having the SDK. My IDE is VS Code. Also when this is available in the stable channel, do you know whether you can directly update this or you have to do a fresh install?Gladiator
@JustCause I see no issue with SDK installation, all is normal. But i don't use VS CodeWhipstock
@hannesach: Great. how is your exprience with the Google maps? Google say it is not working in iOS simulator yet, but works on real device.Gladiator
Does july 27 update means that NDK projects is still not working? ThanksVerbenaceous
@Verbenaceous NDK still runs into Unknown host CPU architecture: arm64 on my side. For this you need the x86 variant, there it worksWhipstock
@JustCause Sorry I missed your Google maps question. Yes, it's working properly with M1Whipstock
Can u please check this #68920116 ?Kristykristyn
It is still lagging when typing code and code completion... bad performance overall.Clouet
@Clouet I only see it in x86 variant. Do you use right arm64 java ? You can choose it in preferences within Gradle settingsWhipstock
I deleted Android Studio and downloaded it again. I‘ve must have overlooked the option to download a Mac M1 x86+arm64 variant. When I had downloaded it before, it probably chose the Intel Version. I now have a little indicator inside the splash screen mentioning arm64 preview. Now code completion runs smoother overall.Clouet
BEWARE that even if it's working, you may find that the M1 version fails to install properly with the error "An error occurred while trying to compute required packages." A workaround is available at that link.Flibbertigibbet
Just wanna say thanks, you saved my day. I'm currently developing an android app on Macbook Pro M1 2020. And I constantly get crash while running Android Emulator.Extramundane
These steps didn't work for me, unfortunately. The emulator process for AVD Nexus_5X_API_30 has terminated.Devonian
I am also facing the similar problem "the emulator process for avd pixel_4a_api_30 has terminated" while trying to use x86 or x86_64 images. But I can run arm-64 images just fine. Any idea about this?Pertinacity
@ImranurRahman Simply use arm-64 imagesWhipstock
@hannesach In my case, I need to use an x86 or x86_64 system image to run a specific application.Pertinacity
This worked for me ! thanks a lot, I waste a lot of time trying to get the solution.Educative
D
81

This fixed my issue

Tools -> SDK Manager -> SDK Tools (tab) -> Deselect 'Android Emulator' -> OK

Now, when you try to run your app, or launch device from AVD Manager, it will give the 'Install Emulator' error -> Click Ok. This will automatically download the correct version.

Doralia answered 27/10, 2021 at 14:27 Comment(6)
This was essential on my M1 MacJennet
Did not work for me on M1.Robin
This has to be the correct solution. because major of developers who faced the issue because of transferring AN from Mac ( inter ) to M1 .. thanks for bring it upSpringhalt
This fixed the issue on my M1 mac. Thanks!Dado
Fixed my issue on M1 mac. Thank you!Schematize
Work for me on M2Hairdo
A
18

I've had this problem with my new Macbook Pro M1 Pro (Macbook Pro 2021 14 Inch M1 Pro). after some digging around, the root of the problem was that I have transferred all my data from my old Mac (using Time Machine) which uses Intel (The other Mac is Macbook Pro 2011 13 Inch Intel), so other than a lot of apps which did not run or ran sluggishly and I had to reinstall their ARM version, the Android SDK Tools were transfered too.

So here are the simple steps to the solution:

  1. Launch Android Studio
  2. Select SDK Managerenter image description here
  3. Go to SDK Tools tabenter image description here
  4. Untick All the Packages, and keep them in your mind because you will retick them in the next step
  5. You will have a dialog something like this, Select Apply. This way now you've uninstalled the old packages enter image description here
  6. retick all packages (to reinstall their ARM version) and click apply, this may take some time depending on your internet speed as you are reinstalling all the packages
  7. Try launching the emulator now, if the problem is not fixed, try restarting Android Studio or your laptop completely, My problem was fixed without restarting though
Across answered 25/3, 2022 at 17:11 Comment(4)
oh my god thank you so much, I was looking for a solution for hours. Had the exact same situation of transferring the data from my intel mac to the m1 mac. Thanks for the great solution!Goldsworthy
@Goldsworthy that's awesome, glad my efforts were not in vainAcross
This works like a charm! Migrated from intel mac to M1 with time machine and had the same issue.Staggard
Thanks, it was an easy and good idea.Putupon
L
11

If everything fails try this:

On Android Studio uncheck emulator -> tools -> Launch in a tool window

enter image description here

Got this from this official issue thread (by jeanlst):

https://github.com/google/android-emulator-m1-preview/issues/76#issuecomment-1023563846

Leuco answered 30/1, 2022 at 17:2 Comment(1)
Actually this resolved my Problem. Just to be clear, I had to uncheck this box to make my Emulators run again on a MacBook with the Apple M1 Max chip.Synecdoche
T
9

I followed the steps that this guy talks and had good results: https://medium.com/mobile-app-development-publication/my-journey-to-setup-android-emulator-for-m1-macbook-pro-b8365321b3e7

  • Go to AVD Manager
  • Click "+ Create Virtual Device"
  • Choose a Device definition (ex. "Pixel 4a XL")
  • Click "Next"
  • Click "Other images"
  • Download "S" System image
  • Click "Next"
  • Click "Finish"
Trimmer answered 9/6, 2021 at 20:46 Comment(3)
I followed this too, but then I got stuck on the "Waiting for devices to come online.." error. Basically, my emulator works, and I can run my Gradle build, but then my app itself never runs on the emulator. After 300s, Android studio times out saying it can't find a device, and add devices shows my emulator as offline. Did you have something similar happen?Cylindroid
I am having same error.Ison
I can see the system image names like 'S' 'R', what does those 'S' 'R' means?Inertia
T
7

Steps to run your Android APP on M1

Finally my Android APP running normally on my M1 chip !

This presume you already have your environment variables set.

  1. Download Android Studio Arctic Fox (2020.3.1) Link (I personally got the last I could September 1, 2021)

  2. Install and open Android Studio

  3. Tools -> SDK Manager

  4. Check the box of Android 12.0 (S) and click Apply

    ... Wait until it's downloaded

  5. Tools -> AVD Manager -> click Create Virtual Device

  6. Choose any device that has the Play button and click Next

  7. Choose the image S. If you can't find it in the Recommended tab click on Other Images

  8. Final step click Next and Finish

You should now be ready to go.

Tiffin answered 7/9, 2021 at 12:45 Comment(1)
unknown error, Consider using an x86 system image on an x86 host for better emulation performance.Lovieloving
M
5

1. First, delete the android studio completely from your Mac system using the following command one by one:

rm -Rf /Applications/Android\ Studio.app  
rm -Rf ~/Library/Preferences/AndroidStudio*  
rm -Rf ~/Library/Preferences/com.google.android.*  
rm -Rf ~/Library/Preferences/com.android.*  
rm -Rf ~/Library/Application\ Support/AndroidStudio*  
rm -Rf ~/Library/Logs/AndroidStudio*  
rm -Rf ~/Library/Caches/AndroidStudio*  
rm -Rf ~/.AndroidStudio*  
rm -Rf ~/.gradle  
rm -Rf ~/.android  
rm -Rf ~/Library/Android*  
rm -Rf /usr/local/var/lib/android-sdk/

To delete all projects:

rm -Rf ~/AndroidStudioProjects 

2. Download the new Android studio using the below link:

https://developer.android.com/studio#downloads:~:text=android%2Dstudio%2D2021.2.1.15%2Dmac_arm.dmg

3. Now install that software, create an emulator using arm version and open that emulator.

Modulus answered 9/6, 2022 at 18:11 Comment(1)
I transferred to a new M2 mac from an Intel mac. When I first opened Android Studio it prompted me to install the ARM version. I did, but couldn't get any emulator to run, even after following the other tips in this thread. After completely uninstalling, as mentioned in this post, did the emulator finally run.Vinyl
L
3

You can now download the Android Studio Canary. In which you can run the android emulator with out any limitation of the android emulator m1 preview. In android emulator m1 preview there are issues with webview , device skin, sound etc..now you dont have to worry about that

Here is the link

https://developer.android.com/studio/preview?gclid=CjwKCAjwm7mEBhBsEiwA_of-TKIWfjv-MVe5W1Za_KcooZ-vfZ3vG_IkUyK40E-x10JLRRgnGjBCDBoCMOgQAvD_BwE&gclsrc=aw.ds

Lett answered 2/5, 2021 at 18:13 Comment(2)
Yes, but after an update it stops working for me. In the meantime I did github.com/741g/android-emulator-m1-preview/issues/… and now I'm able to use it seamless againWhipstock
Oh, but its working fine for me. Previously with android emulator m1 preview i had issue with the webview and sound. But now its all fixed for me with this Android Studio Canary releaseLett
H
3

as @Dipanker Shah reply, unclick the Android Emulator and run the AVD. After that... android studio will pop a warning screen and press OK. IDE will download the correct version.

Uncheck the Android Emulator and apply which will delete the existing files, and Recheck it and apply for new installation which will download compatible Android Emulator for M chips. 1

Hayner answered 14/8, 2022 at 3:12 Comment(3)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Then
Reinstalling the emulator via unticking/reticking was what got it to work for me! Thanks.Kovar
Success !! My Android Studio Dolphin | 2021.3.1 Patch 1 faced the same issue with M1 Pro. By Deleting (unchecking) existing Android emulator and reinstalling (by checking) solved the issue. Thank you @Hayner for clarity.Paraclete
A
2

For me I can run the emulator on my MacBook Pro MacOS Big Sur with ARM CPU M1 only on Android Studio Arctic Fox (2020.3.1 Beta03 and later versions) only after deleting Intel x86 Emulator Accelerator (HAXM installer).

Abampere answered 14/7, 2021 at 7:26 Comment(1)
You definitely don't need HAXM on Apple Silicon. -Never-Whipstock
Q
2

After I install the latest AndroidStudioPreview for Mac M1, it already included a default simulator with arm64-v8a ABI. However, this simulator still not loaded by AndroidStudio

When I tried to run adb from Terminal, it shows adb: command not found. So I config the adb

  • I set adb environment variable follow this answer
  • After that, when I run adb, I get the error zsh: bad CPU type in executable
  • Then I fix it by softwareupdate --install-rosetta (follow this answer)
  • Restart Terminal, then adb command working well
  • Restart AndroidStudio, then it able to see and run app to simulator
Quijano answered 20/12, 2021 at 2:5 Comment(0)
P
1

Now It's available

Apple Silicon Support

Android Studio Arctic Fox Canary 15 contains preliminary support for Apple Silicon (arm64). This version of Android Studio for this platform is still under active development, but we wanted to get a functional version out to the app developer community to get feedback. On top of the Intellij build, design tools work, and the Android Emulator works with API 30 and API S Developer Preview emulator system images.

Click here to Download

Pifer answered 31/5, 2021 at 8:23 Comment(0)
J
1

This works for me with Android Studio 2020.3.1:

  1. Tools -> AVD Manager -> click Create Virtual Device
  2. Pick any one of the Hardware that has Play Store, e.g. Pixel 4
  3. Click Other Images tab, download and select the S API Level
  4. Click Next and Finish

Then you're good to go!

I don't have any issue so far with the performance of my emulator which is nice.

Source/Credit to author of: https://medium.com/mobile-app-development-publication/my-journey-to-setup-android-emulator-for-m1-macbook-pro-b8365321b3e7

Jordanson answered 7/9, 2021 at 9:48 Comment(0)
F
1

Simple answer for M1 :

  1. Uninstall Android studio
  2. Delete all related files, check (Vikas Awate's answer @ https://mcmap.net/q/35861/-android-studio-emulator-on-macos-with-arm-cpu-m1) :
rm -Rf /Applications/Android\ Studio.app
rm -Rf ~/Library/Preferences/AndroidStudio*  
rm -Rf ~/Library/Preferences/com.google.android.*  
rm -Rf ~/Library/Preferences/com.android.*  
rm -Rf ~/Library/Application\ Support/AndroidStudio*  
rm -Rf ~/Library/Logs/AndroidStudio*  
rm -Rf ~/Library/Caches/AndroidStudio*  
rm -Rf ~/.AndroidStudio*  
rm -Rf ~/.gradle  
rm -Rf ~/.android  
rm -Rf ~/Library/Android*  
rm -Rf /usr/local/var/lib/android-sdk/
  1. Re-install Android Studio Arctic Fox (check for the latest version here) : https://developer.android.com/studio/archive

Everything will work much better after that. Inspired from crg's answer : https://mcmap.net/q/35861/-android-studio-emulator-on-macos-with-arm-cpu-m1

Ferric answered 25/4, 2023 at 17:30 Comment(0)
D
0

It is not clear exactly what problems Google has had that they still have no way to release the M1 version. I got the DTK M1 almost a year ago. I think Google got it even earlier. Yes, there was a problem with emulation, but everything else in the IDE could definitely be done.

At least a loner did it without too much trouble. There is roughness, but the speed of work is different from sky and earth. Working with a regular Android Studio on M1 is almost impossible, and even with this refinement amateur, everything flies like lighting.

Here is the link: https://github.com/dsa28s/android-studio-apple-m1

This is an unofficial canary version of Android Studio Arctic Fox with emulators on the Apple Silicon. I'm using it and it works well in most cases.

Dartmoor answered 18/6, 2021 at 13:37 Comment(2)
Did you read my answer https://mcmap.net/q/35861/-android-studio-emulator-on-macos-with-arm-cpu-m1 ? There is a link to aarch64 Beta4 included. All for M1Whipstock
Yes, at last. :)Dartmoor
N
0

Android Studio now has an official production release that supports the ARM chip. 2020.3.1.26

Naif answered 10/1, 2022 at 9:45 Comment(2)
It's since 28th July 2021. Please see my answer https://mcmap.net/q/35861/-android-studio-emulator-on-macos-with-arm-cpu-m1Whipstock
@hannesach - I'm sorry but your answer links to a non-production buildNaif
E
0

For me none of the solutions worked. Tried Arctic fox, bumblebee and etc. The only thing that worked was the Dolphin canary version. As you install this version, it gives you a default emulator but it's also possible to create a new one without any issue. Of course, there could be issues (because its canary ver.) but I'm happy that I can run something at this point.

Emplane answered 10/2, 2022 at 20:9 Comment(0)
A
0

In the emulator window (when all emulator tabs are closed) click on "Update" link and update developer tools.

Acrogen answered 12/2, 2022 at 21:41 Comment(0)
V
0

I ended up doing this Hack to manually install the emulator from the Dev Documentation https://developer.android.com/studio/emulator_archive

Valentia answered 3/6, 2022 at 16:36 Comment(1)
Which emulator did you install?Ceiba
M
0

When you have this problem now with an M1 or M2 Chip and you have transfered your android studio with the copy-functionality from an old Intel Mac, check that you also uninstall the Haxm-part of the emulator. This was my problem. In my case I also wasn't able to remove that easily,thats why I deleted everything from android studio on my Mac and reinstalled after that. Then everything worked like a charm.

Mimimimic answered 13/12, 2022 at 7:41 Comment(0)
E
0

In my case, I had to make sure to select an arm compatible system image (see screenshot below)

enter image description here

Elbertelberta answered 25/10, 2023 at 16:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.