简体   繁体   English

在未经验证的Android设备上运行本机C程序

[英]Run a native C program on unrooted Android device

I've managed to build a native executable for Android, after reading How do I build a native (command line) executable to run on Android? 在阅读了如何构建在Android上运行的本机(命令行)可执行文件后,我设法为Android 构建了一个本机可执行文件? , but I can't execute it on my unrooted phone, it gives 但我不能在我的无根电话上执行它

/system/bin/sh: /storage/sdcard0/Download/hello_world: can't execute: Permission denied / system / bin / sh:/ storage / sdcard0 / Download / hello_world:无法执行:权限被拒绝

because the SD card is mounted with noexec , and I can't write anywhere else. 因为SD卡安装了noexec ,我无法在其他任何地方写入。

I found a solution that works for me - it seems that /data/local/tmp is writable, and it isn't on a noexec partition. 我找到了一个适合我的解决方案 - 似乎/data/local/tmp是可写的,并且它不在noexec分区上。

The solution requires using adb . 该解决方案需要使用adb I connected the phone through USB, and I enabled USB debugging from developer options. 我通过USB连接了手机,并从开发人员选项中启用了USB调试。

Then I uploaded the file to the phone using: 然后我使用以下命令将文件上传到手机:

adb push C:\Workspace\hello_world\libs\armeabi\hello_world /data/local/tmp/hello_wo
rld

Then I ran adb shell: 然后我运行了adb shell:

adb shell

And from it I changed the write permission, and ran it: 从中我改变了写权限,然后运行它:

chmod 755 /data/local/tmp/hello_world
/data/local/tmp/hello_world

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在无根设备中运行Shell命令 - How to run shell command in unrooted device 是否可以在无根的普通android设备上启用checkjni? - Is it possible to enable checkjni on unrooted normal android device? 想以编程方式从未经验证的Android设备的ram中清除未使用的内存 - Want to clean unused memory from ram of unrooted android device programatically / system / app中的Android应用程序可以在无根设备上写入/ system吗? - Can an Android app in /system/app write into /system on unrooted device? 是否可以通过编程方式重新引导有根和无根的android设备? - Is it possible to reboot both rooted & unrooted android device Programmatically? SQLite文件能否成功复制到未经授权的Android设备的数据文件夹中? - Can SQLite file copied successfully on the data folder of an unrooted android device ? 将Android设备从用户切换到工程师版本,反之亦然? 从根设备到无根设备? - Switch android device from user to engineer version and vise-versa? Root device to Unrooted device? React Native 无法在 Android 设备中运行 - React Native won't run in Android device 无法在Android设备上运行react-native - Unable to run react-native on android device 如何在Android设备(例如Samsung galaxy tab)上运行ac或c ++程序? - How to run a c or c++ program on a Android Device like Samsung galaxy tab?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM