按照 http://developer.android.com/tools/sdk/ndk/index.html 中的步骤操作。我有 动态库,例如:“armeabi”文件夹下的libhello-jni.so(ABI对应ARMv5TE)。
我的问题是: 如果我使用基于 ARMv5TE 的 CPU。我的动态库 libhello-jni.so 将使用 THE EABI。并且在该CPU上运行的JVM也将使用EABI,因为它们使用相同的ABI,因此它们可以相互交互。这是正确的吗?
最佳答案
请参阅 Android NDK 文档了解更多详细信息(请参阅 NDK 文件夹根目录下的 documentation.html
)。
如果您引用CPU Arch ABIs
部分,部分III.3
解释了用于选择正确机器代码的机制:
When installing an application, the package manager service will scan the .apk and look for any shared library of the form
lib/<primary-abi>/lib<name>.so
[...] [it] ensures that the best machine code for the target device is automatically extracted from the package at installation time.
换句话说,系统会自动选择正确的库。
关于java - Android: native 代码如何与java代码交互?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19948182/