[英]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.