Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will an app built with only armeabi run on armeabi-v7a devices?

The Xamarin documentation is a bit unclear on this. If I build my app with only armeabi ticked in the build preferences, will my app:

  1. Be available for v7a devices in the Play Store?
  2. Run on v7a devices?

If it does run, are there any features like using threads that will lead to unexpected behaviour or crashes?

I've got a simple app and am trying to keep it small. Also, I don't have a v7a device to do a quick experiment.

Clarification:

While there seems to be clear acceptance that it is "safe, but not so performant" to compile an Android app with only the amreabi library (see this excellent post: Why use armeabi-v7a code over armeabi code?), the Xamarin docs on CPU architecture, that I assume applies to their compiled .so libraries, says:

it is important to remember that the armeabi runtime used by Xamarin.Android is thread safe. If an application that has armeabi support is deployed to an armeabi-v7a device, many strange and unexplainable exceptions will occur.

I have since been able to test my app that is just compiled with armeabi on a v7a device and haven't run into any "strange and unexplainable exceptions" YET.

Update:

Looks like the Xamarin docs has since been updated and now (2014-07-14) reads:

it is important to remember that the armeabi runtime used by Xamarin.Android is not thread safe. If an application that has armeabi support is deployed to an armeabi-v7a device, many strange and unexplainable exceptions will occur.

like image 497
Jannie Theunissen Avatar asked Jul 02 '13 15:07

Jannie Theunissen


People also ask

Which is better Armeabi-v7a or arm64-v8a?

armeabi-v7a is the older target, for 32 bit arm cpus, almost all arm devices support this target. arm64-v8a is the more recent 64 bit target (similar to the 32-bit -> 64 bit transition in desktop computers).

Can arm64-v8a run Armeabi-v7a?

64-bit devices also support their 32-bit variants. Using arm64-v8a devices as an example, the device can also run armeabi and armeabi-v7a code.

What is Armeabi?

EABI - Embedded Application Binary Interface. So ARMEABI are compiled binaries matching your android device's CPU architecture. e.g. arm64-v8a (Nexus 5x) - 64bit - ARM Cortex-A35, ARM Cortex-A53, ARM Cortex-A57, ARM Cortex-A72, ARM Cortex-A73.


1 Answers

According to the Xamarin Android documentation, armeabi code will crash in unexpected ways on a multi-core armeavi-v7 device.

http://docs.xamarin.com/guides/android/advanced_topics/cpu_architecture

Section 1.1

Note: Xamarin.Android’s armeabi code is not thread safe and should not be used on multi-CPU armeabi-v7a devices (described below). Using aremabi code on a single-core armeabi-v7a device is safe.

The reason that Xamarin Android make it a requirement to include armeabi-v7a has to do with thread safe memory access. Put simply the armeabi instruction set lacks the instructions necessary to safely lock memory on SMP devices.

The most thorough discussion of the issue can be found in this bug report: https://bugzilla.xamarin.com/show_bug.cgi?id=7013

Jonathan Pryor 2012-09-20 11:41:45 EDT

As far as I can determine, it is (nearly) IMPOSSIBLE to SAFELY use an armeabi library on a SMP armeabi-v7a device. This is because armeabi lacks the CPU instructions necessary to safely lock data on SMP devices, so if the armeabi library contains data that must be protected against access from multiple threads, it's busted, and libmonodroid.so is such a library. This may be fixable by creating a libmonodroid.so which dynamically determines the runtime CPU, allowing it to use either armeabi or armeabi-v7a lock instructions accordingly, but this has not been done yet, and the implementation timeframe is unknown.

Thus, if your app will be running on SMP hardware, you should include the armeabi-v7a runtime with your app. This can be done in the Project Options dialog.

These crashes are rare but catastrophic and very hard to debug as you experience random memory corruption and segmentation faults.

I was able to reproduce the issue reliably on a Galaxy S3. Some example code that demonstrates the crash is in this bug report: https://bugzilla.xamarin.com/show_bug.cgi?id=7167


It's unknown whether or not this bug affects other NDK applications on Android. But it definitely affects Xamarin Android.

like image 57
Jared Kells Avatar answered Sep 19 '22 08:09

Jared Kells