Run ARM apps on the Android Emulator
Posted oncealong
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Run ARM apps on the Android Emulator相关的知识,希望对你有一定的参考价值。
以前debug android程序都是用实体机debug,没有用虚拟机的原因是手机App里带有第三方so,这些so还只有armeabi架构,直接运行在虚拟机里会直接crash。找过一些x86模拟arm的插件,但是效率堪忧,慢的折腾人。
最新AS官方退出了Android 11的模拟器,可以直接利用x86的cpu的能力,只中转需要的代码,大家可以试下。
我已经在MAC上试过了,启动过程中crash一次,安装两个app,安装完成后都crash,完全没法使用。不过这是官方项目,长远看好,大家可以在自己系统上试下。
转自:https://android-developers.googleblog.com/2020/03/run-arm-apps-on-android-emulator.html
Run ARM apps on the Android Emulator
26 March 2020
Posted by Michael Hazard
As part of the Android 11 developer preview we’ve released Android 11 system images, which are capable of executing ARM binaries with significantly improved performance. Previously, developers who were dependent on ARM libraries and could not build an x86 variant of their app either had to use system images with full ARM emulation, which are much slower than x86 system images when run on x86-based computers, or resort to physical devices. The new Android 11 system images are capable of translating ARM instructions to x86 without impacting the entire system. This allows the execution of ARM binaries for testing without the performance overhead of full ARM emulation.
The new Android 11 (Google APIs) x86 system image supports ARM ABIs, while the older Android Oreo system image does not
Details
The significance of this may require a bit of context, especially if you build apps exclusively with Kotlin or the Java programming language. Unlike Kotlin or the Java programming language, both of which execute on the Android Runtime (ART), any C++ in your Android app compiles directly into machine instructions. This means that it needs to be compiled differently based on the architecture of the target device. Mobile phones tend to have ARM processors; consequently, many C++ dependencies you might add to your app, like a camera barcode scanner library, are only compatible with ARM processors. This is a problem if you develop on a computer with an x86-based processor, as it would prevent you from running your app.
Previously, if you wanted to get around this limitation and execute an app built for ARM on your x86 machine, you would have had to use an emulator system image with full ARM emulation. Due to the overhead of translating an entire system’s worth of ARM instructions to x86, emulator system images with full ARM emulation tend to run much slower than x86-based system images when run on x86 host machines. Additionally, emulator system images with full ARM emulation cannot take advantage of the hardware acceleration and CPU virtualization technologies provided by x86 processors.
The new ARM-compatible Android 11 system images allow the entire system to run x86 natively and take advantage of virtualization technologies as usual. When an app’s process requires an ARM binary, the binary is translated to x86 within that process exclusively. This allows the rest of the process to continue executing in x86, including the Android Runtime (ART), and other performance-critical libraries like libGLES and libvulkan. In addition to this, the translator avoids expensive memory access instrumentation and the associated performance hit by avoiding the execution of low-level hardware-specific libraries. These new emulator system images can be used both locally and on your own continuous integration infrastructure. This is possible thanks to collaboration with ARM Limited.
Going Forward
If you have previously chosen physical devices over the emulator due to the lack of performant ARM support, try out the Android 11 system images, which are now available alongside the Android 11 Developer Preview. These system images can be downloaded in Android Studio via either the SDK Manager or the Android Virtual Device Manager.
Using the Android Virtual Device Manager to create an AVD that runs Android 11
Once you get your app running on the emulator, consider adapting it for Chrome OS. Chrome OS also supports the execution of Android apps built for ARM on x86 laptops. Building for Chrome OS provides access to a substantial ecosystem of larger screen devices, allowing your application to reach even more users globally.
This technology should enable more developers to test with the Android Emulator. That said, we still recommend that developers publish both x86 and ARM ABI variants of their apps to achieve the best physical device performance and reach as many users as possible. Going forward, we plan to roll this technology out across a wider variety of API levels and ensure that it supports testing all use cases that a physical device would. Given that this is a new technology, please let us know of any problems via our Issue Tracker.
Note that the ARM to x86 translation technology enables the execution of intellectual property owned by Arm Limited. It will only be available on Google APIs and Play Store system images, and can only be used for application development and debug purposes on x86 desktop, laptop, customer on-premises servers, and customer-procured cloud-based environments. The technology should not be used in the provision of commercial hosted services.
Java is a registered trademark of Oracle and/or its affiliates.
以上是关于Run ARM apps on the Android Emulator的主要内容,如果未能解决你的问题,请参考以下文章
react项目运行出现进度卡住,Would you like to run the app on another port instead?
react项目运行出现进度卡住,Would you like to run the app on another port instead?
flask run之后仍然报running on the 127.0.0.1:5000
flask run之后仍然报running on the 127.0.0.1:5000
解决 genymotion 安装apk报错 app contains ARM native code and your Genymotion device cannot run ARM instruc
bzoj1742[Usaco2005 nov]Grazing on the Run 边跑边吃草*&&bzoj3074[Usaco2013 Mar]The Cow Run*