如何在64位的Andr​​oid-L平台使用32位本机库 [英] how to use 32bit native libraries on 64 bit Android-L platform

查看:1380
本文介绍了如何在64位的Andr​​oid-L平台使用32位本机库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我与AOSP(奇巧)编译一个Android应用程序的Andr​​oid系统的应用程序,它运行良好。我的应用程序依赖于与Android的NDK编译为32位本机库code。我复制本机库在我的Andr​​oid应用程序的库/ armeabi 文件夹,然后建立我的Andr​​oid应用程序在AOSP(我也修改 device.mk 复制我的库中的< STRONG> /系统/ lib目录文件夹)。一切工作正常在Android奇巧。

I have a Android application which i compiled with AOSP(Kitkat) as android system application and it was running fine. My application is dependent on native code compiled with Android-NDK as 32 bit libraries. I am copying native libraries inside my android applications libs/armeabi folder and then building my android application in AOSP(I have also modified device.mk to copy my libs in the /system/lib folder). Everything is working fine on Android Kitkat.

当我移植我的应用程序在Android-L(64位平台),那么我是不是能够从Android应用程序和错误加载我的机库是像 -

When i ported my application on Android-L(64bit platform) then i am not able to load my native libraries from Android application and error is like -

java.lang.UnsatisfiedLinkError中:dlopen的失败:libfoobar.so

是32位的,而不是

我使用下面的Java code加载机库 -

I am using following java code to load native library-

        if ( ENABLE_ANDROID_INTEGRATION )
        {
            System.load("/system/lib/libfoobar.so");
        }
        else
        {
            System.loadLibrary("foobar");
        }

当我建立我的code与AOSP然后点击 ENABLE_ANDROID_INTEGRATION 真正

When i am building my code with AOSP then ENABLE_ANDROID_INTEGRATION is true

更有趣的是,当我关掉 ENABLE_ANDROID_INTEGRATION ,并建立我在Eclipse的应用程序,AOSP外面作为一个正常的下载应用程序,然后我的应用程序运行良好的64位Android平台。

More interestingly when i turned off ENABLE_ANDROID_INTEGRATION and build my application in Eclipse, outside AOSP as a normal "downloadable" application then my application is running fine on 64bit Android platform.

我想知道什么 - 如何建立我的应用程序与32位库(这意味​​着AOSP版本)的64位Android平台

What i want to know - how can i build my application as a native android system application with 32 bit libraries(that means AOSP build) for 64 bit Android platform?

我曾尝试 - 我用的 LOCAL_32_BIT_ONLY = TRUE 标记在我的Andr​​oid应用程序的Andr​​oid.mk文件,但它接缝是没有用的。可能是我没有充分意识到这个标志的使用。

What i have tried - I used LOCAL_32_BIT_ONLY = true flag in my android application's Android.mk file, but it seams it is not useful. May be i am not fully aware of this flag use.

由于我的时间不多了,所以我preferred发布此问题在这里的一群,而不是RND。如果有人遇到这种问题,那么请指导。

As i am running out of time so i preferred to post this question here in group instead of RnD. If anyone faced this problem then please guide.

问候, Meraj

推荐答案

为什么它当作为一个第三方的应用程序安装正常工作的原因是,在安装时,包管理器扫描APK并检查它是否使用了本机库,并如果这样的发现,它存储了ABI他们使用(因为只安装了一个单一的ABI库,所以信息哪些选择是做需要存储在某个地方)。

The reason why it works when installed as a third party application, is that on installation, the package manager scans the APK and checks if it uses native libraries, and if such are found, it stores which ABI they used (since it only installs libraries for one single ABI, so the info about which choice was made needs to be stored somewhere).

对于与在/系统/ lib中的库安装全系统的应用,目前还不清楚这一特定的应用程序依赖于/系统/ lib中的一些应用程序专用库(不在一个64位版本可用/系统/ lib64的),所以封装/应用程序管理器可以不知道此特定的应用程序需要特定的ABI和因而运行它在64位模式

For an application that is installed system wide with the libraries in /system/lib, it's not clear that this particular application depends on some app specific libs in /system/lib (that aren't available in a 64 bit version in /system/lib64), so the package/application manager can't know that this particular app requires a specific ABI and thus runs it in 64 bit mode.

设置LOCAL_32_BIT_ONLY可能只会影响它是否应该在32位模式下,不能以何种方式应该运行进行编译。

Setting LOCAL_32_BIT_ONLY probably only affects whether it should be compiled in 32 bit mode, not in which way it should be run.

在一个古老的(也​​可能是过时的)报告<一href="http://www.slideshare.net/hidenorly/investigation-result-on-64-bit-support-in-aosp">http://www.slideshare.net/hidenorly/investigation-result-on-64-bit-support-in-aosp似乎表明,对于应用程序的本地库应该进入/系统/ lib中/的 apkname 的,但是这似乎并没有一个实际的Andr​​oid 5.0系统上是正确的。取而代之的是,库似乎是在/系统/应用/的应用程序名称的/ lib目录/ abiname 的。一些应用程序似乎对多种架构天然库(例如两个臂和arm64作为 abiname 的),而另一些仅具有一个单一的架构(这​​将迫使过程在ABI将要开始模式)。

An old (and probably outdated) report at http://www.slideshare.net/hidenorly/investigation-result-on-64-bit-support-in-aosp seems to suggest that the native libraries for apps should go into /system/lib/apkname, but this doesn't seem to be true on an actual Android 5.0 system. Instead, the libs seem to be in /system/app/appname/lib/abiname. Some apps seem to have native libs for multiple architectures (e.g. both "arm" and "arm64" as abiname), while others only have one single architecture (which would force the process to be started in that ABI mode).

所以,我认为你需要改变的机制,你如何安装你的本机库(你说你手动修改device.mk) - 我不熟悉如何构建自己的应用程序作为的AOSP版本的一部分,但我倒是建议想看看现有的应用程序捆绑在一起,他们是怎么做到的,这种承诺可能涉及:<一href="https://android.googlesource.com/platform/packages/apps/Terminal/+/1a161f75%5E%21/">https://android.googlesource.com/platform/packages/apps/Terminal/+/1a161f75%5E%21/

So I think you need to alter the mechanism for how you install your native libraries (you said you manually modified device.mk) - I'm not familiar with how to build own apps as part of an AOSP build, but I'd recommend trying to look at the existing bundled apps how they do it, this commit may be related: https://android.googlesource.com/platform/packages/apps/Terminal/+/1a161f75%5E%21/

这篇关于如何在64位的Andr​​oid-L平台使用32位本机库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆