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.
I solved by changing the value of 'android.defaultConfig.targetSdkVersion' from '29' to '28' in 'build.gradle(Module: app)'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With