Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot run program "/data/data/my.app.package/files/my-executable": error=13, Permission denied

I copy a binary executable to the location context.getFilesDir() which is the path /data/data/my.app.package/files/my-executable.

File permission of /data/data/my.app.package/files/my-executable is -rwxr-xr-x

Then I try to execute a command with the java ProcessBuilder like:

commands = Arrays.asList("/data/data/my.app.package/files/my-executable", "ls");
ProcessBuilder pb = new ProcessBuilder(commands);
pb.redirectErrorStream(true);
final Process p = pb.start();

The statement pb.start() throws the following IOException:

Caused by java.io.IOException: error=13, Permission denied
       at java.lang.UNIXProcess.forkAndExec(UNIXProcess.java)
       at java.lang.UNIXProcess.<init>(UNIXProcess.java:133)
       at java.lang.ProcessImpl.start(ProcessImpl.java:141)
       at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)

Cannot run program "/data/data/my.app.package/files/my-executable": error=13, Permission denied

I have no root access on the test phone. Until Android version 9 (API 28) it was working fine. Starting from Android 10 (API 29) I get the above IOException.

How can I run my executable in Android 10+ ? Does it work in another directory? Thanks for your help.

like image 856
user4500 Avatar asked Mar 04 '26 19:03

user4500


1 Answers

I solved by changing the value of 'android.defaultConfig.targetSdkVersion' from '29' to '28' in 'build.gradle(Module: app)'.

like image 186
yibo Avatar answered Mar 07 '26 08:03

yibo