Android上的可写和可执行文件的位置 [英] Writeable and Executable location on Android

查看:417
本文介绍了Android上的可写和可执行文件的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编译使用Android NDK工具链二元,并在尝试将它部署到一个设备上。其中已建成使用NDK使用JNI的应用程序将执行通过本地code这个二进制文件。我希望避免生根设备。

I've compiled a binary using the Android NDK toolchain, and am attempting to deploy it to a device. An application which has been built with the NDK using JNI will then execute this binary via native code. I'm hoping to avoid rooting the device.

二进制文件将被多个应用程序使用,所以我想将它存储在共享位置,而不是每一次应用。

The binary will be used by multiple applications, so I'd like to store it in a shared location, rather than once per application.

我无法找到一个合适的位置来部署这个二进制文件 - 这是我试过的地方:

I can't find an appropriate location to deploy this binary to - these are the places I've tried:


  1. 的/ mnt / SD卡 - 使用的 getExternalStoragePublicDirectory()的从SDK,但是SD卡安装为NOEXEC,这意味着我不能运行它。

  1. /mnt/sdcard - using getExternalStoragePublicDirectory() from the SDK, however the SD card is mounted as noexec, meaning I can't run it.

/系统/斌 - 只读文件系统,因此无法复制。我可以使用亚行推推的文件,如果我重新安装/系统仿真器上使用:

/system/bin - read-only file system, so can't copy. I can push the file using adb push if I remount /system on the emulator using:

mount -o rw,remount -t yaffs2 /dev/block/mtd3 /system

不过,我想避免这种情况,作为设备将需要扎根。

However I'd like to avoid this, as the device would need to be rooted.

/数据/本地 - 亚行使用推,我可以二进制推到这个​​位置。不过,我似乎无法找到一种方法,在code要做到这一点(使用Android SDK)。内部存储机制分的 /数据/数据​​/包

/data/local - using adb push, I can push the binary to this location. However, I can't seem to find a way to do this in code (using the Android SDK). The internal storage mechanism points to /data/data/package.

我编译的本地code调用该可执行文件,使用的 ARM-Linux的androideabi-G ++ 的随NDK工具链。这适用于二进制的 /系统/斌的和的 /数据/本地的。

I've compiled native code which calls this executable, using arm-linux-androideabi-g++ shipped with the NDK toolchain. This works with the binary in /system/bin and /data/local.

总之,我正在寻找在Android文件系统中的位置,我可以从项目/资产文件夹,这世界可执行的权限是可以复制文件。

In summary, I'm looking for a location in the Android file system to which I can copy a file from the project /assets folder, which world-executable permissions are possible.

推荐答案

如果你想避免生根设备,然后基本上SD卡,你可以假设的唯一地方是世界上可写(修改:心灵最近的变化在Android框架为2014/2015!)。这是更好地使安装APK的二进制文件的一部分,然后提取该双星明APK入私存,使它成为可执行文件等,并以某种方式宣布二进制位置,但一般预期这取决于操作系统版本和供应商

If you want to avoid rooting the device then basically SD card is the only place you can assume is world writeable (EDIT: mind recent changes in Android framework as of 2014/2015!). It's better to make your binary part of installable APK which then extract this binary out of APK into private storage, make it world executable etc and somehow announce binary location, but in general expect some problems depending on OS version and vendor

这篇关于Android上的可写和可执行文件的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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