为什么使用armeabi-v7a 代码而不是armeabi 代码?
在我当前的项目中,我使用多个 .so 文件。它们位于armeabi 和armeabi-v7a 文件夹中。不幸的是,其中一个 .so 文件大小为 6MB,我需要减小文件大小。我只想使用armeabi 文件并删除armeabi-v7a 文件夹,而不是使用胖APK 文件。
根据NDK文档,armeabi-v7a代码是扩展的armeabi代码,可以包含额外的CPU指令。这一切都超出了我的专业知识,但我质疑为什么人们想要同时拥有armeabi-v7a和armeabi代码。两者都必须有充分的理由,对吗?
在我的测试设备上,这一切似乎都工作正常。它们具有 ARM v7 CPU。可以安全地假设现在一切正常吗?
In my current project I make use of multiple .so files. These are located at the armeabi and armeabi-v7a folder. Unfortunately one of the .so files is a 6MB and I need to reduce file size. Instead of having a fat APK file, I would like to use just the armeabi files and remove the armeabi-v7a folder.
According to the NDK documentation, armeabi-v7a code is extended armeabi code which can contain extra CPU instructions. This all goes beyond my expertise, but I question why one would like to have both armeabi-v7a and armeabi code. There must be a good reason to have both, right?
On my test devices this all seem to work fine. These have ARM v7 CPU's. Is it safe to assume that everything works now?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
取决于您的本机代码的功能,但 v7a 支持硬件浮点运算,这会产生巨大的差异。 armeabi 在所有设备上都能正常工作,但速度会慢很多,并且无法利用较新设备的 CPU 功能。请针对您的特定应用程序进行一些基准测试,但删除 armeabi-v7a 二进制文件通常不是一个好主意。如果您需要减小大小,您可能需要为旧设备 (armeabi) 和新设备 (armeabi-v7a) 提供两个单独的 apk。
更新 2012-09; Google 的 Play 商店终于支持上传不同的 APK(每个 APK 针对不同的 CPU 架构),即所谓的“多个 APK”功能:
https://developer.android.com/google/play/publishing/multiple-应用程序
但更新 2023;Google 建议创建“应用程序包”而不是使用“多个 APK”功能:
https://developer.android.com/guide/app-bundle
Depends on what your native code does, but v7a has support for hardware floating point operations, which makes a huge difference. armeabi will work fine on all devices, but will be a lot slower, and won't take advantage of newer devices' CPU capabilities. Do take some benchmarks for your particular application, but removing the armeabi-v7a binaries is generally not a good idea. If you need to reduce size, you might want to have two separate apks for older (armeabi) and newer (armeabi-v7a) devices.
Update 2012-09; Google's Play Store finally has support for uploading different APKs (each targeting a different CPU architecture), with the so-called "multiple APKs" feature:
https://developer.android.com/google/play/publishing/multiple-apks
But Update 2023; Google recommends creating "App bundle" instead of using "multiple APKs" feature:
https://developer.android.com/guide/app-bundle
EABI = 嵌入式应用程序二进制接口。可执行文件必须符合这样的规范才能在特定的执行环境中执行。它还指定了用于 ARM 架构的工具链之间互操作所需的编译和链接的各个方面。在这种情况下,当我们谈论 armeabi 时,我们谈论的是 ARM 架构和 GNU/Linux 操作系统。 Android 遵循小端 ARM GNU/Linux ABI。
armeabi 应用程序将在 ARMv5(例如 ARM9)和 ARMv6(例如 ARM11)上运行。如果您使用正确的 GCC 选项(如 -mfpu=vfpv3 -mfloat-abi=softfp)构建应用程序,则可以使用浮点硬件,它告诉编译器为 VFP 硬件生成浮点指令并启用软浮点调用约定。 armeabi 不支持硬浮点调用约定(这意味着 FP 寄存器不用于包含函数的参数),但仍然支持硬件中的 FP 操作。
armeabi-v7a 应用程序将在 Cortex A# 设备(例如 Cortex A8、A9 和 A15)上运行。它支持多核处理器,并且支持-mfloat-abi=hard。因此,如果您使用 -mfloat-abi=hard 构建应用程序,许多函数调用将会更快。
EABI = Embedded Application Binary Interface. It is such specifications to which an executable must conform in order to execute in a specific execution environment. It also specifies various aspects of compilation and linkage required for interoperation between toolchains used for the ARM Architecture. In this context when we speak about armeabi we speak about ARM architecture and GNU/Linux OS. Android follows the little-endian ARM GNU/Linux ABI.
armeabi application will run on ARMv5 (e.g. ARM9) and ARMv6 (e.g. ARM11). You may use Floating Point hardware if you build your application using proper GCC options like -mfpu=vfpv3 -mfloat-abi=softfp which tells compiler to generate floating point instructions for VFP hardware and enables the soft-float calling conventions. armeabi doesn't support hard-float calling conventions (it means FP registers are not used to contain arguments for a function), but FP operations in HW are still supported.
armeabi-v7a application will run on Cortex A# devices like Cortex A8, A9, and A15. It supports multi-core processors and it supports -mfloat-abi=hard. So, if you build your application using -mfloat-abi=hard, many of your function calls will be faster.
相反的是一个更好的策略。如果您将
minSdkVersion
设置为 14 并将您的 apk 上传到 Play 商店,您会发现无论您是否支持armeabi
,您都将支持相同数量的设备。因此,没有任何 Android 4 或更高版本的设备可以从armeabi
中受益。这可能就是 Android NDK 根据修订版 r17b 不再支持
armeabi
的原因。 [来源]The opposite is a much better strategy. If you have
minSdkVersion
to 14 and upload your apk to the play store, you'll notice you'll support the same number of devices whether you supportarmeabi
or not. Therefore, there are no devices with Android 4 or higher which would benefit fromarmeabi
at all.This is probably why the Android NDK doesn't even support
armeabi
anymore as per revision r17b. [source]