android - 仅使用 armeabi 构建的应用程序能否在 armeabi-v7a 设备上运行

Xamarin documentation对此有点不清楚。如果我在构建首选项中仅勾选 armeabi 构建我的应用程序,我的应用程序会:

  1. 可以在 Play 商店中使用 v7a 设备吗?
  2. 在 v7a 设备上运行?

如果它确实运行,是否有任何功能,例如使用线程会导致意外行为或崩溃?

我有一个简单的应用程序,并试图保持它的小。另外,我没有 v7a 设备来做一个快速实验。

澄清:

虽然似乎已明确接受仅使用 amreabi 库编译 Android 应用程序是“安全的,但性能不高”(参见这篇出色的帖子:Why use armeabi-v7a code over armeabi code?),但 Xamarin docs on CPU architecture ,我认为适用于他们编译的 .so 库,说:

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.

我已经能够在 v7a 设备上测试我刚刚使用 armeabi 编译的应用程序,并且还没有遇到任何“奇怪且无法解释的异常”。

更新:

看起来 Xamarin 文档已经更新,现在 (2014-07-14) 显示为:

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.

最佳答案

根据 Xamarin Android 文档,armeabi 代码会在多核 armeavi-v7 设备上以意想不到的方式崩溃。

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.

Xamarin Android 要求包含 armeabi-v7a 的原因与线程安全内存访问有关。简而言之,armeabi 指令集缺少安全锁定 SMP 设备上的内存所需的指令。

可以在此错误报告中找到对该问题最彻底的讨论: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.

这些崩溃很少见,但却是灾难性的,而且在您遇到随机内存损坏和段错误时非常难以调试。

我能够在 Galaxy S3 上可靠地重现该问题。一些演示崩溃的示例代码在此错误报告中:https://bugzilla.xamarin.com/show_bug.cgi?id=7167


尚不清楚此错误是否会影响 Android 上的其他 NDK 应用程序。但它肯定会影响 Xamarin Android。

关于android - 仅使用 armeabi 构建的应用程序能否在 armeabi-v7a 设备上运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17429139/

相关文章:

.net - IoC 容器,在编译时检查错误

c++ - Visual Studio 2010 - 在不同的构建配置之间保留项目属性?

build - Xamarin:使用 NDK 构建的 .so

perl - 有没有最简单的方法来构建 perl 包

maven - 是否有从 Maven 到 Bazel 的迁移路径?

image - Docker:构建你自己的镜像问题

c# - C# 中的友元程序集

c++ - C++ 项目的 cmake vs waf

c# - Visual Studio 2010 构建错误 - 来自 HRESULT : 0x8003

java - Maven 构建顺序(多个模块)