Android Emulator On Macbook M1

My first impression of setting up Android App Development on an M1 MacBook Pro is not as positive as I hope to get it, as my blog below. It is working, but it is not ideal in various. Apr 14, 2021 My first impression of setting up Android App Development on an M1 MacBook Pro is not as positive as I hope to get it, as my blog below. It is working, but it is not ideal in various way. Apple requires W^X (Write Xor Execute) conformance for native macOS M1 applications. What it does is make it so that areas of memory must be explicitly marked as for Write or Execute, but not both! Because it's easier and hasn't been forbidden on any of the prior platforms that Dolphin supports, the emulator previously just marked memory. The Android Emulator is finally supported on Apple Silicon natively and I'm testing it out on my M1 MacBook Air. I also compare it to the native iOS Simulato. React native setup for Android Emulator.on Macbook M1 2021 - check my other video for iOS simulator.

From the announcement made on November 10th, 2020, users have had high hopes for the new Apple M1 devices. With its powerful Apple Silicon processor smashing benchmarks all over the place, users and developers were both asking if a native Dolphin build would be possible. Now we have the answer.

Android emulator on macbook m1 freeAndroid

Apple's M1 hardware is incredibly powerful and excels at running Dolphin. This announcement has been in the works for some time, eagle eyed users may have noticed that earlier this month macOS builds were now being designated as 'Intel'. That's because delroth and Skyler had set up a new buildbot using a service called MacStadium for creating Universal macOS binaries. These builds are available immediately and natively support both macOS M1 and Intel macOS devices.

Tackling macOS on ARM¶

It is an understatement to say that Apple dropped a bomb on the PC industry with the M1 ARM processor. ARM is a Reduced Instruction Set Computing (RISC) architecture that was specifically designed for efficiency with portable devices. With a tight instruction set instead of the ever ballooning mess that is x86, ARM was able to get away with literally less processor while performing optimized tasks, giving it exceptional power efficiency. However given unoptimized workloads, an ARM processor would need many more cycles to perform it than an x86 CPU. All combined, ARM was the processor of choice for battery life in portable devices, but when pushed they had poor overall performance compared to Intel's x86 processors. It was a processor for casual things like phones, and not really meant for 'real work'. But that is the past.

Intel's iron grip of process superiority has long slipped, and the ARM instruction set has carefully expanded to more efficiently handle more tasks while not sacrificing power efficiency. Yet even with ARM reaching datacenters and even some interesting hardware giving us a glimpse at what could be, ARM's reputation as being weaker than x86 has remained firmly entrenched.

But with M1, Apple has completely shattered this foolish notion. Not only can the M1 perform the same tasks as their former Intel processors, they can do it faster even when using their Rosetta 2 translation layer! All of this while still providing considerably better single threaded performance compared to Intel. Let's just say they had gotten our attention.

We immediately put it through its paces. Using the Rosetta 2 translation layer with Dolphin's x86-64 JIT, the M1 easily ran most games at full speed and handily outran like-class Intel Macs. The experience wasn't entirely smooth due to jitter from Jitting a JIT, yet the processor proved itself more than capable of handling Dolphin. But the fact it had to do it through a translation layer was a huge performance bottleneck. Developers thought, why not just use Dolphin's AArch64 JIT for native support? And thus, the race was on as several people tried to figure out the hurdles of getting Dolphin's AArch64 JIT to run on the M1.

Unfortunately, getting the AArch64 JIT to work wasn't exactly trivial. Apple requires W^X (Write Xor Execute) conformance for native macOS M1 applications. What it does is make it so that areas of memory must be explicitly marked as for WriteorExecute, but not both! Because it's easier and hasn't been forbidden on any of the prior platforms that Dolphin supports, the emulator previously just marked memory regions used by the JIT as for WriteandExecute. This requirement from Apple is mostly a security feature to prevent bugs in programs that read untrusted data from being exploited to run malware. Outside of emulators, the primary place that you'll actually see self-modifying code is web browsers, which is often a vector for attack on a computer.

This was thankfully a lot less strict than on iOS devices, which strictly forbid mapping memory as executable whatsoever and made iOS untenable for us to officially support. Apple even provides documentation for helping developers port JITs to macOS on ARM. Skyler used a method described in the documentation that would change the mapped memory between Writeable when emitting code to Executable when executing code. Since Dolphin wasn't designed for this, there were a few hiccups along the way, but eventually everything was massaged into working with the new restrictions.

Once that was out of the way, the focus shifted towards maintainability and setting up the infrastructure. Beyond getting it to run correctly, this was by far the hardest challenge to official M1 support. Dolphin's infrastructure is rather complicated and sensitive to changes. Moving macOS builds over to a universal binary (x86-64 and AArch64 all in one) along with getting the hardware necessary to build macOS universal binaries was a challenge and could have proven to be an expensive endeavor. In the end, MacStadium made the move extremely inexpensive by providing us with free access to M1 hardware, so we were able to focus on making Dolphin's buildbot infrastructure handle the new builds.

Putting the M1 Hardware To The Test¶

So now that it runs, you're probably wondering how does it run. There's a few things we need to keep in mind. Dolphin's AArch64 JIT isn't quite as mature as the x86-64 JIT. While things aren't as bad as they were a couple of years ago and compatibility should be roughly the same thanks to efforts from JosJuice, it is still the less complete of the two JITs.

One of the differences is instruction coverage. Any PowerPC instruction that isn't included in the JIT has to fallback to interpreter, which costs a huge performance penalty. Most common instructions are covered by both JITs at this point. There is one important feature missing in the AArch64 Jit, though: memchecks. Thankfully, this only affects Full MMU games such as Star Wars Rogue Squadron II, III, and Spider-Man 2. There are some niceties missing from AArch64 JIT, too, like JitCache space reuse used to prevent spurious JitCache flushes.

AArch64 does have its advantages, though. Namely, the processors have 31 registers, compared to the 16 available in x86-64 processors. The PowerPC processor we are emulating has 32 registers, and while it is rare for all of them to be used within a single code block, more registers is always nice to have. Another difference is that AArch64 and PowerPC have 3 operand instructions while x86-64 only has two.



As you can see, it makes emulating some instructions much cleaner and easier than on our x86-64 JIT. Alright, enough with the boring details. How does the M1 hardware perform when put up against some of the beasts of the GameCube and Wii library? We also included data from two computers featured in Progress Reports previously for comparison.

Android Emulator On Macbook M1


There's no denying it; macOS M1 hardware kicks some serious ass. It absolutely obliterates a two and a half year old Intel MacBook Pro that was over three times its price all while keeping within ARM's reach of a powerful desktop computer. We were so impressed, we decided to make a second graph to express it.


The efficiency is almost literally off the chart. Compared to an absolute monstrosity of a Desktop PC, it uses less than 1/10th of the energy while providing ~65% of the performance. And the poor Intel MacBook Pro just can't compare.

Taking Things a (Lock)Step Further¶

After doing strenuous performance testing on the macOS M1 and its Apple Silicon, it was clear that it was powerful. The problem is that if you give developers a new toy, they eventually decide to push things further and further. This was the first time we got to see Dolphin's AArch64 JIT really stretch its legs on something other than a phone or tablet with an ultra aggressive governor that's also limited by graphics drivers. What is the absolute worst idea that we could come up with given this new found power? Netplay.

This was the real test to see if the AArch64 JIT and x86-64 JIT truly equals. We couldn't exactly test this before because the Android GUI lacks netplay support, but macOS runs the desktop version with no compromises. That includes having full netplay support. Now, testing this was mostly a joke because there are tons of differences between the JITs. Everything from instruction coverage to known rounding errors. The chances of this working was next to zero. But there was no reason to stop and think if we should - technology had made it so we could.

And it actually worked! We just can't be certain exactly how well yet due to limited testing. Every single game we've tested on netplay so far has managed to synchronize, albeit with Dolphin's desync checker giving a false positive. Testers have tried everything from Super Smash Bros. Melee and Mario Party 5 to things like spectating The Legend of Zelda: The Wind Waker. All of the sessions stayed in sync.

This might not be true for all games. Up until earlier this month, games like Mario Kart: Double Dash!!, F-Zero GX, and Mario Kart Wii would immediately desync due to physics differences. Thanks to the work of JosJuice, those rounding bugs in the AArch64 JIT and interpreter (...we'll get to that in the Progress Report) are now fixed, meaning these games should at least have a chance to sync on netplay.

Because of limited libraries, we don't have a great idea of what games will work and what games are problematic. As a stress test, Techjar and Skyler played the Super Mario Sunshine Co-op Mod. The physics calculations in Super Mario Sunshine are extremely sensitive to CPU rounding bugs and it provided a tough test for both JITs. Oh yeah, they also enabled the 60 FPS hack just to make things even more interesting.

Everyone knowledgeable on Dolphin's JITs thought that cross-JIT netplay would be impossible, at least without tons of dedicated fixes. Yet here we are, able to experience it first hand. And it can only get better from here, as we are now able to monitor and test JIT determinism on netplay. While you might be excited to dive right in, it's important to note that we were only able to test a few games and we have no idea what compatibility will look like when unleashed on the wider library.

Note:Yes, we're aware that Windows and Linux AArch64 devices existed before the M1. There was no allure to testing netplay on those because they could not run Dolphin reasonably. We really didn't expect this to work or we probably would have tried it sooner.

In Conclusion¶

There's little else we can say: The M1 hardware is fantastic and higher tiers are on the way promising even better performance. But what we have is already efficient, powerful, and gives us a mainstream AArch64 device that isn't Android and uses our AArch64 JIT to its fullest potential. The only big downside is the proprietary graphics API present in macOS that prevents us from using the latest versions of OpenGL and forces us to use MoltenVK in order to take advantage of Vulkan. That is a very small price to pay to get a glimpse at some really cool hardware that redefines what an ARM processor can do. There's undeniable excitement for the next generation of AArch64 hardware to see how much further that this can go.

EDITORS NOTE: A small error was noticed in our 9900k performance testing. This has been corrected. However, the differences are very minor and do not affect our conclusion.

I have OSX EI caption 10.11.3 mid 2013 MBA with an Intel i5 processor. The problem is that when I Create play an app which I'm making on AVD on Android Studio, AVD shows the gray screen like this:

Also shows these error messages on android studio

03-08 16:04:52.790 2114-2114/com.example.apple.omikuji_app I/art: Not late-enabling -Xcheck:jni (already on)

Android Emulator On Macbook M1

03-08 16:04:52.860 2114-2130/com.example.apple.omikuji_app D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true

03-08 16:04:52.900 2114-2114/com.example.apple.omikuji_app D/Atlas: Validating map...

03-08 16:04:52.970 2114-2130/com.example.apple.omikuji_app I/OpenGLRenderer: Initialized EGL, version 1.4

03-08 16:04:52.990 2114-2130/com.example.apple.omikuji_app D/OpenGLRenderer: Enabling debug mode 0

Android Emulator On Macbook M1

03-08 16:04:53.010 2114-2130/com.example.apple.omikuji_app W/EGL_emulation: eglSurfaceAttrib not implemented

Android Emulator On Macbook M1 Download

03-08 16:04:53.010 2114-2130/com.example.apple.omikuji_app W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7feff4cd50c0, error=EGL_SUCCESS

Android Emulator On Macbook M1 Free

Any ideas?

Android Emulator Mac Apple M1

Test your English vocabulary size, and measure
how many words do you know

See also questions close to this topic

  • How do I move these two items in my navigation drawer down to the bottom?

    I want to figure out a way to move these two items down my navigation drawer, how do I do it and is it possible to do with icons? Here is the image.

    Here is my Hamburger Menu Code

  • Trying to run periodic code in background of flutter

    I am working on a app where a requirement is to run a piece of code periodically every half hr. The code must be triggered/invoked using push notification sent from FCM.

    Now the question if the user has closed the app in background and since the code must run on background without user involvement. Can a push notification be used to trigger a code and the notification stays hidden from the user.

    Or a completely new approach should be taken like looking into scheduling method likehttps://pub.dev/packages/cron

    Thanks,Ryan

  • Firebase Storage URL error due to invalid Token - Android

    I'm having trouble retrieving the icon´s images from Firebase Storage to my Xamarin.Android app because the (Dynamic) Token that is appended to the URL of the images eventually changes (for security reasons).

    The icons in the app are loaded using FFImageLoading, but when passing the static link (uri) that is stored in the source code, the ImageView does not show the icons because the token expired (it is no longer valid).

    Image link example in Firebase Storage (uri):

    Expired token that is at the end of the URL (uri) mentioned above:

    Reading Image in ImageView with FFImageLoading:

    Question:How can this be resolved?

    Is it possible that the Firebase Storage URL is static (i.e. not constantly changing)?

    Or How do I get a new valid Token?

    (Can´t find much info regarding this issue and Xamarin Android, so any tip will help.)

  • Display text instead of pin on MKMapview

    Working on an OSX app and Im wondering how to make a custom MKAnnotationView that will just show the text of the item instead of a red pin, thanks. Right now I think the problem is the ViewForAnnotation is not being called in my class which extends MKMapView

    EDIT:

  • Bidirectional sharing between the MacBook Pro and Debian 8 not working

    The bi-directional sharing between the MacBook Pro and Debian 8 in the VirtualBox not working. I set in the,

    However, at the time I right click on the Debian machine, I see the paste option is inactive. What else I need to check?

  • Can't complete a clean install of macOS High Sierra from USB. Macintosh HD not becoming a start up disk

    I am trying to do a clean install of macOS High Sierra. I've done clean installs of macOS plenty of times, but I have never had this problem. I am booting into my installation media on USB. The installation tools appear as they should. I'm using Disk Utility to erase Macintosh HD into a clean APFS drive. I then select Install macOS and follow the prompts, select Macintosh HD, and it restarts. However, Macintosh HD does not become a startup disk -- I just reboot into the USB installer media. In Disk Utility, there's 5GB of content on the disk, but it does not appear in the Startup Disk menu nor if I hold option on boot. What's going on here? First Aid says the drive is fine.

  • How to make dynamic URL endpoint in KOTLIN

    I want to make dynamic URL_ENDPOINT. The problem is 'An annotation argument must be a compile-time constant' and I don't know how to pass data to that interface.Every solution I found was for JAVA and I can't convert it to Kotlin.

    Interface with Api service:

    Function where I get data about books from Google Books API

  • Kotlin RecyclerView - Update item to DB

    I have a category item in my recyclerView.There is a TextView and two ImageView as button (Edit button and Delete button).When I click edit button I want to change TextView to EditText and editbutton change for agreebutton. When I write new text just update my old one.I show you what I have and almost everything working but don't update my new text and I know code don't look nice and maybe someone can show me how to do it better :)

  • No Resource Manager in Android Studio

    There's no Resource Manager in my Android Studio. Do I have a limited version or why it's not there?

    All help is highly appreciated, thanks in advance :)

  • Can't start Android 12 AVD, but can start Android 11 AVD

    I've been developing and testing my app using an Android 11 AVD without problems. Now i wanted to test Android 12 and created a new AVD using an Android 12 image. But when i start the AVD, it spawns a qemu process, but i don't see any window and nothing happens (even after 30 minutes). I've tried various images and reinstalling the whole SDK.

    Here is a log from starting the emulator in the terminal:

    I'm using Manjaro, Kernel 5.14, latest Nvidia drivers.

  • How to get different API versions for a System Image in AVD Manager?

    I have downloaded all the API versions. Here is what my SDK Manager tab looks like.

    But when I try to create a new Virtual device I do not see the option to create Virtual Device other than API 28 and API 23.

    My Virtual Device Configuration Page looks like.

    This is what I want

    How can I get the multiple options to create Virtual device with different API level (Oreo, Nougat, Pie etc.)

  • How to delete android virtual device release version, in android studio?

    I selected Oreo 8.0 as Android virtual device release name. Now I want to delete that release version and download another. How do I delete Oreo 8.0?

    Also this is my first question here. :)

  • AVD Emulator will not start (MacBook)

    I have installed Android Studio 3.3.2 on my Macbook (MoJave 10.14.3), but cannot get the AVD device emulator to work with the following error:

    I found the Pixel_XL_API_28.ini and Pixel_XL_API_28.avd in the '/private/var/root/.android/avd' folder and the following paths have been added to bash_profile (as below)

    If I run the emulator from the command line

    I receive the following error message:

    (Note: Directories are searched in the order $ANDROID_AVD_HOME, $ANDROID_SDK_HOME/avd and $HOME/.android/avd)

    Is there any way to fix this problem or change the directory to point to somewhere else to find the appropriate files?

  • Android Emulator is not running on Android Studio 3.3.2 (MacBook Air)

    I have installed Android Studio 3.3.2, I had some problems with the SDK path and I cannot run the app from my application icon, but from the terminal window using sudo ./studio. I had to set the SDK path and re-install SDK into a new folder.

    Now I cannot run the AVD emulator and I get the following error messages:

    I have been through all the other fixes, such as re-installing Android Studio, re-installing the emulation, Intel x86 Emulator accelerator enabled, deleting all the virtual devices and re-building them.

    There is one problem, which is my MacBook keeps reporting 'Your disk is almost full' currently have 1.5GB spare space on the drive.

    I have been through all the other fixes, such as re-installing Android Studio, re-installing the emulation, Intel x86 Emulator accelerator enabled, deleting all the virtual devices and re-building them.

    I have read the path might be set wrong for the AVD drivers, but cannot see anywhere these are present in the Android Studio.

    Could the problem be with the lack of space disk space or something else going?

  • 'Error Creating AVD. An error occurred while crating the AVD. See idea.log for details ' Studio vers. 3.32 in Ubuntu vers. 18.04

    I can't create an AVD for a very famous error: 'Error Creating AVD.An error occurred while crating the AVD. See idea.log for details 'with Anfroid Studio 3.3.2 and Ubuntu 18.04.

    I tried all the solutions present on stackoverflow and not only but without success.

    I attach the error and warning part of the idea.log file:

    Please guide and thanks in advance.