我的Android应用程序需要将C ++ .so库放在哪里 [英] Where to put c++ .so library needed for my android application

查看:97
本文介绍了我的Android应用程序需要将C ++ .so库放在哪里的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个基于ndk的android应用程序,当我通过单击Android Studio中的运行"按钮运行它时,我发现该应用程序已安装并在连接的android设备上运行.但是它抱怨说它无法加载某些.so文件,例如 libc ++ _ shared.so libomp.so ,我做了一些研究,并创建了一个 jniLibs放在我的 app \ src \ main 文件夹中,然后将这两个.so文件复制到其中,现在一切正常.

I made an ndk based android app, and when I run it by clicking the run button in Android Studio, I found the app been installed, and running on my connected android device. But it complains that it could not load some .so files like libc++_shared.so and libomp.so, I did some research, and created a jniLibs in my app\src\main folder, and copied those two .so files into that, now everything works fine.

但是,我仍然不清楚发生了什么事:

However, it is still unclear to me what happened exactly:

  1. 当我单击运行按钮时,该应用程序在设备上的安装/保存位置以及.so文件是否已复制到同一位置?
  2. 我怀疑将.so文件复制到 jniLibs 是否是一个好习惯,这样的.so文件可以被许多应用程序共享,如果每个应用程序都有自己的副本,则更新它们将变得很困难.有没有办法将它们存储在公用位置以供应用共享?
  3. 我还可以在不同应用程序之间共享android设备上的.so文件吗?
  1. when I click the run button, where the app is installed/saved on the device, and is the .so files copied to the same location?
  2. I suspect if it is a good practice to copy the .so files to the jniLibs, such .so files could be shared by many apps, updating them become difficult if every app has its own copy. Is there are way to store them in a common place to be shared by apps?
  3. May I also share the .so files on the android device across different apps?

推荐答案

  1. 当我单击运行按钮时,该应用程序在设备上的安装/保存位置以及.so文件是否已复制到同一位置?

App保存在/data/app/your.app.name-cert-hash == 上,.so库存储在同一位置,例如/data/app/your.app.name-cert-hash ==/lib/x86 (如果AndroidManifest.xml/application中的 android:extractNativeLibs ="true" ,否则库将直接压缩为.apk).

App is saved on /data/app/your.app.name-cert-hash== and .so libraries are stored in the same location, e.g. /data/app/your.app.name-cert-hash==/lib/x86 (if android:extractNativeLibs="true" in AndroidManifest.xml/application, otherwise libraries are directly compressed to .apk).

要发现Android文件系统,您可以使用ADB(以及仿真器):

For discovering Android file system you can use ADB (with emulator as well):

  1. 从AS运行您的应用

  1. Run your app from AS

以su模式运行adb shell:

Run adb shell in su mode:

adb shell
su
ls -als /data/app

  1. 我怀疑将.so文件复制到jniLib中是否是一个好习惯,这样的.so文件可以被许多应用程序共享,如果每个应用程序都有自己的副本,则更新它们将变得很困难.有没有办法将它们存储在公用位置以供应用共享?

由于Android安全方法,这是不可能的.

It is not possible due to Android security approach.

  1. 我还可以在不同应用程序之间共享android设备上的.so文件吗?

否.

这篇关于我的Android应用程序需要将C ++ .so库放在哪里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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