permission is denied using Android Q ffmpeg": error=13, Permission denied-ThrowExceptions

Exception or error:

Hi I want to get the frames from the rtsp video using ffmpeg. In android 10 it is working fine. I am getting the frames. In android 10 I am getting error like this.

 E/FFmpeg: Exception while trying to run: [Ljava.lang.String;@55e447f Cannot run program "/data/user/0/com.example.downloadimagefromurl/files/ffmpeg": error=13, Permission denied
    at java.lang.ProcessBuilder.start(
    at java.lang.Runtime.exec(
    at java.lang.Runtime.exec(
    at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(
    at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(
    at android.os.AsyncTask$
    at android.os.AsyncTask$SerialExecutor$
    at java.util.concurrent.ThreadPoolExecutor.runWorker(
    at java.util.concurrent.ThreadPoolExecutor$
 Caused by: error=13, Permission denied
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(

Please anyone help to resolve the issue in android 10. thanks in advance.

How to solve:

From Android Q onwards, you cannot execute binaries in your app’s private data directory.

From the issuetracker:

The change to block exec() on application data files for targetAPI >=
Q is working-as-intended. Please see
for background on this change. Calling exec() on writable application
files is a W^X ( violation and
represents an unsafe application practice. Executable code should
always be loaded from the application APK.

While exec() no longer works on files within the application home
directory, it continues to be supported for files within the read-only
/data/app directory. In particular, it should be possible to package
the binaries into your application’s native libs directory and enable
android:extractNativeLibs=true, and then call exec() on the /data/app
artifacts. A similar approach is done with the functionality,
documented at

Additionally, please be aware that executables executed via exec() are
not managed according to the Android process lifecycle, and generally
speaking, exec() is discouraged from Android applications. While not
Android documentation,
Using "exec()" with NDK
covers this in some detail. Relying on exec() may be problematic in
future Android versions.

Leave a Reply

Your email address will not be published. Required fields are marked *