I need a specific command line tool and I have made a C program in my Linux shell. I have compiled the program with an ARM cross-compiler. I have then moved the program into the Android file system and tried to run it.

The output is permission denied.

What do I have to do, in order to run my own compiled programs in Android file system?


I assume that you used adb push for uploading your executable to the sd-card. Unfortunately the sd-card is always mounted with "noexec" which means that you can't execute anything from here.

Therefore you have to copy the executable to the local filesystem, e.g. to /data/local. In case the device is not rooted or you don't have BusyBox installed there will be no "cp" command. You can simply use cat: cat /sdcard/myprog > /data/local/myprog.

Then you have to set the executable permission on the executable. Chmod on android usually does not support the "u+x" syntax. Therefore you have to call chmod 555 /data/local/myprog.

Afterwards you can execute your executable: /data/local/myprog.

Alternatively the directory /data/local/tmp can be used. Via adb shell you have full access in this directory. On modern devices (Android 11+) apps can't list files from this directory, but they are still able to execute executables from there if you provide the full path of the executable.

  • Thx for your reply. In fact the problem was on the binary generation. It was not being generated correctely! ;) May 27 '13 at 9:43
  • I have busybox on my device, but this command: shell@n200C:/ $ busybox cp /storage/external_storage/sda1/ffmpeg /data/ ------ show error= cp: can't create '/data/ffmpeg': Permission denied
    – Dr.jacky
    Nov 16 '15 at 13:58
  • tmp-mksh: /data/local/workspace/clang+llvm-5.0.0-aarch64-linux-gnu/bin/clang++: No such file or directory though the file is present
    – Necktwi
    Mar 8 '18 at 15:59
  • /data/local requires root access on my device. Use /data/local/tmp instead
    – Chan Tzish
    Feb 4 '20 at 13:26

First, you have to push it into a directory, such as /data/local/tmp. Then, you have to set permission for that using chmod 755 executable. After that, you can run it as ./executable.

Complete steps are as follows:

adb push executable /data/local/tmp
adb shell
cd /data/local/tmp
chmod 755 executable

Alternatively, if you want to run it from your asset folder, you have to copy the file to your data folder /data/data/packagename/. Then using File class, set the setExecutable flag to true for the file and run it by the Process class or third party packages like Root Tools .

if you are targeting sdk 29 or higher you CANNOT use the binary from your asset folder ! you have to copy your binary to jnilib folder then run it from native library directory ! context.getApplicationInfo().nativeLibraryDir

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.