Android的NDK:在不同的体系结构ABI使用相同的库 [英] Android NDK: Use same library across different ABI architectures

查看:188
本文介绍了Android的NDK:在不同的体系结构ABI使用相同的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个后续问题:<一href=\"http://stackoverflow.com/questions/19358130/android-ndk-compiling-different-libraries-for-different-architectures\">Android NDK:编译不同体系结构不同的库

我的问题是我有两个C ++与NDK编译JNI库。一个是小和结构相关的,而另一个是一个很大的库,它是相同的不同的体系结构。为了使小.apk文件,我宁愿只有一个大图书馆的副本。我尝试了文件夹结构是这样的:

 的lib / armeabi / libbig.so
LIB / armeabi / libsmall.so
LIB / armeabi-V7A / libsmall.so

然而,当我跑它V7设备上,我得到了一个的UnsatisfiedLinkError。当我在设备上的libs文件夹选择,只有libsmall.so安装。我的问题是:是否有可能有一些图书馆体系结构无关的而有些则是体系结构相关。事情是这样的:

 的lib / armeabi / libsmall.so
LIB / armeabi-V7A / libsmall.so
LIB /所有/ libbig.so


解决方案

我相信,如果V7A提升是如此重要,那么你可以简单地放弃对非V7设备的支持。也有建立和上传不同的ABI单独的APK的选项:的https: //developer.android.com/google/play/publishing/multiple-apks.html

最后,你可以重新排列库如下:

 的lib / armeabi / libbig.so  - &GT; LIB / armeabi / libbig.so
LIB / armeabi / libsmall.so - &GT; LIB / armeabi / libsmall.so
LIB / armeabi-V7A / libsmall.so - &GT; LIB / armeabi / libsmall-v7a.so

这样,你的Java应用程序应该选择小V7A的<一个href=\"http://developer.android.com/reference/java/lang/System.html#loadLibrary%28java.lang.String%29\"相对=nofollow>的System.loadLibrary()。

This is a followup question to : Android NDK : Compiling different libraries for different architectures

My issue is I have two c++ JNI libraries compiled with NDK. One is small and architecture dependent, and the other is a big library which is the same across architectures. In order to make the .apk smaller, I would rather have only one copy of the big library. I tried a folder structure like this:

lib/armeabi/libbig.so
lib/armeabi/libsmall.so
lib/armeabi-v7a/libsmall.so

However, when I ran it on a v7 device, I got an UnsatisfiedLinkError. When I checked in the libs folder on the device, only libsmall.so was installed. My question is: is it possible to have some libraries architecture-independent while others are architecture-dependent. Something like this:

lib/armeabi/libsmall.so
lib/armeabi-v7a/libsmall.so
lib/all/libbig.so

解决方案

I believe that if v7a boost is so important, then you can simply drop support for non-v7 devices. There is also the option to build and upload separate APKs for different ABIs: https://developer.android.com/google/play/publishing/multiple-apks.html.

Finally, you can rearrange the libraries as follows:

lib/armeabi/libbig.so           --> lib/armeabi/libbig.so
lib/armeabi/libsmall.so         --> lib/armeabi/libsmall.so
lib/armeabi-v7a/libsmall.so     --> lib/armeabi/libsmall-v7a.so

This way, your Java app should choose "small" or "small-v7a" for System.loadLibrary().

这篇关于Android的NDK:在不同的体系结构ABI使用相同的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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