简体   繁体   中英

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? , 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

because the SD card is mounted with noexec , and I can't write anywhere else.

I found a solution that works for me - it seems that /data/local/tmp is writable, and it isn't on a noexec partition.

The solution requires using adb . I connected the phone through USB, and I enabled USB debugging from developer options.

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

And from it I changed the write permission, and ran it:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM