Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission denied running version command when targeting Android Q #126

Open
darrinps opened this issue Jul 26, 2019 · 40 comments
Open

Permission denied running version command when targeting Android Q #126

darrinps opened this issue Jul 26, 2019 · 40 comments

Comments

@darrinps
Copy link

darrinps commented Jul 26, 2019

Not sure if it's because I am running Android Q beta, or I'm doing something wrong but I am getting the following:

2019-07-26 12:29:01.320 24329-24408/com.android.testffmpeg E/FFmpeg: Exception while trying to run: [/data/user/0/com.android.testffmpeg/files/ffmpeg, -version]
java.io.IOException: Cannot run program "/data/user/0/com.android.testffmpeg/files/ffmpeg": error=13, Permission denied
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1050)
at nl.bravobit.ffmpeg.ShellCommand.run(ShellCommand.java:15)

All I am doing is calling this function:

`
private fun versionFFmpeg() {
FFmpeg.getInstance(TestFFmpegApplication.instance.applicationContext)
.execute(arrayOf("-version"), object : ExecuteBinaryResponseHandler() {
override fun onSuccess(message: String?) {
Timber.d(message)
}

            override fun onProgress(message: String?) {
                Timber.d(message)
            }
        })

}

`

The only setup I have in the code is this:

implementation 'nl.bravobit:android-ffmpeg:1.1.7'

Can anyone see what it is I am missing, or perhaps there is an issue running on Android Q?

@darrinps
Copy link
Author

darrinps commented Jul 26, 2019

Looks like it's Q. If I build and run your sample app verbatim, it works, but when I change the compile and target SDK to be 29....crash. Same as I see in my app. So I think this looks to be a fairly high bug given Q will be released shortly.

@darrinps darrinps changed the title Permission denied running version command Permission denied running version command when targeting Android Q Jul 26, 2019
@alexcohn
Copy link

alexcohn commented Aug 7, 2019

Tried this on Q emulator, system-images\android-29\google_apis\x86, and it simply worked.

@alexcohn
Copy link

alexcohn commented Aug 11, 2019

I have updated the Q emulator (now it is [google/sdk_gphone_x86/generic_x86:10/QPP6.190730.005.B1/5775370:userdebug/dev-keys]), and the it does not permit to run ffmpeg from the files directories anymore. Or maybe the trigger is that I set targetSdk=29.

Actually, this is a documented change.

The fix is to move ffmpeg from assets to jniLibs.

alexcohn added a commit to alexcohn/FFmpeg-Android that referenced this issue Aug 11, 2019
alexcohn added a commit to alexcohn/FFmpeg-Android that referenced this issue Aug 11, 2019
@desaibijal
Copy link

Someone has solution to run ffmpeg commands in android Q its urgent??

@kartik1225
Copy link

Any updates on this?

@kazemihabib
Copy link

Hi,
I didn't try it myself but probably you can fix it with adding

android:requestLegacyExternalStorage="true"

to application in AndroidManifest.xml

@kartik1225
Copy link

kartik1225 commented Dec 27, 2019

No, it still does not work

@WassimErriha
Copy link

Try this library
I just tested it on a physical device running Android Q (android 10)

@PO15ON
Copy link

PO15ON commented Feb 15, 2020

@WassimErriha Thanks, it worked.

@Aditya94A
Copy link

Any updates on this?

Or is this the end of this library?

@Le-Dinh-Nam
Copy link

Le-Dinh-Nam commented Mar 8, 2020

I found solution on this issue.
https://issuetracker.google.com/issues/128554619

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 wrap.sh functionality, documented at https://developer.android.com/ndk/guides/wrap-script#packaging_wrapsh .

It works well on my project(tested on Pixel 3a XL android Q)

@AmioLee
Copy link

AmioLee commented Mar 12, 2020

I have updated the Q emulator (now it is [google/sdk_gphone_x86/generic_x86:10/QPP6.190730.005.B1/5775370:userdebug/dev-keys]), and the it does not permit to run ffmpeg from the files directories anymore. Or maybe the trigger is that I set targetSdk=29.

Actually, this is a documented change.

The fix is to move ffmpeg from assets to jniLibs.

I have create jniLibs folder then move the lib from assets,but still not work,
Is there something i miss?

@alexcohn
Copy link

I have create jniLibs folder then move the lib from assets,but still not work,
Is there something i miss?

It's much more than simply renaming some folders, see #130

@vincent-paing
Copy link

Why hasn't this been merged yet, even Android 11 is about be released, has this project been abandoned?

@pratikbutani
Copy link

Just change targetSdkVersion 29 to 28 in build.gradle

It worked for me.

@kibotu
Copy link

kibotu commented May 5, 2020

@pratikbutani not a solution that works on higher android versions

@pratikbutani
Copy link

@kibotu
It's working on higher version too. I have checked on Android 10.

@SnehaDZ
Copy link

SnehaDZ commented May 11, 2020

not working for me

@aliraza96
Copy link

NOT WORKING FOR ME TOO. Have anyone found an answer to this problem?

@alexcohn
Copy link

@SnehaDZ @aliraza96 if you can set targetSdkVersion less than 29, your app will continue to work even on Android 11 (a.k.a. Android R). Note that this does not prevent you from using the new Android Q APIs in your code.

But if you want to switch to 29, you can try my fork. In the long run, I would recommend to switch to another library, even though this means that your code must be changed: with every upgrade, Android becomes less open to running executables in the context of an app.

@Ahmed-Basalib10
Copy link

any update ?

@kdsrsl
Copy link

kdsrsl commented Jul 20, 2020

still unrepaired

@iamkdblue
Copy link

any update?

@vincent-paing
Copy link

We're using this library instead now, which is still maintained actively

https://github.com/tanersener/mobile-ffmpeg

@1nikolas
Copy link

1nikolas commented Jul 23, 2020

You can take a look on my approach on the original repo. I basically moved ffmpeg to the libs folder and renamed it to libffmpeg.so (should start with lib and end with .so in order for this to work). Then I added android:extractNativeLibs = "true" to the manifest so the binary is moved into data/app/{package_name}/lib/{arch}/, where it can me executed on Android 10.

There is a problem with this though. You have to put the binaries 4 times in the apk (if you want an apk that supports all architectures). The only way to have the binaries 2 times is to build the apk for arm and x86 only (so it can use the x86 binary on x64 and arm binary for arm64). But then playstore wont let you upload your app because it doesn't have native x64 support.

@AamirNaseer1
Copy link

I have updated the Q emulator (now it is [google/sdk_gphone_x86/generic_x86:10/QPP6.190730.005.B1/5775370:userdebug/dev-keys]), and the it does not permit to run ffmpeg from the files directories anymore. Or maybe the trigger is that I set targetSdk=29.

Actually, this is a documented change.

The fix is to move ffmpeg from assets to jniLibs.

how can I move from assets to JNI libs?

@iamkdblue
Copy link

use this
implementation 'com.arthenica:mobile-ffmpeg-full:4.3.1.LTS'

@plazar99
Copy link

use this
implementation 'com.arthenica:mobile-ffmpeg-full:4.3.1.LTS'

I tried this, ffmpeg -version hits onFailure.
do I need to do load library with this version. The 0.3.2 from writingminds required it.

@alexcohn
Copy link

@plazar99 normally, the library loads its native part by itself. But your mileage may vary.

@plazar99
Copy link

I just rebuild it for sdktarget 28, no difference. I'm afraid I'm missing something fundamental here.

@plazar99
Copy link

I figured out my mistake. I followed the example provided,

  1. implementation 'com.arthenica:mobile-ffmpeg-full:4.3.1.LTS' <=== do not use this
    ===> use this implementation 'nl.bravobit:android-ffmpeg:1.1.7'

2.use this => ffmpeg.execute(ffcommand, new FFcommandExecuteResponseHandler() {
dont use the one in the example provided.

This fixed everything.

@nivas412
Copy link

You can take a look on my approach on the original repo. I basically moved ffmpeg to the libs folder and renamed it to libffmpeg.so (should start with lib and end with .so in order for this to work). Then I added android:extractNativeLibs = "true" to the manifest so the binary is moved into data/app/{package_name}/lib/{arch}/, where it can me executed on Android 10.

There is a problem with this though. You have to put the binaries 4 times in the apk (if you want an apk that supports all architectures). The only way to have the binaries 2 times is to build the apk for arm and x86 only (so it can use the x86 binary on x64 and arm binary for arm64). But then playstore wont let you upload your app because it doesn't have native x64 support.

How you moved ??

@aliraza96
Copy link

aliraza96 commented Aug 21, 2020 via email

@kadnan0900
Copy link

kadnan0900 commented Dec 2, 2020

i didn't see any clear fixed please guide me to solve this issue.

@alexcohn
Copy link

alexcohn commented Dec 2, 2020

i didn't see any clear fixed please guide me to solve this issue.

See #126 (comment)

@plazar99
Copy link

plazar99 commented Dec 2, 2020

I gave up on this version of ffmpeg, I was able to get it working, but noticed that when running large number of ffmpeg (120) the number of failures were too much. I went back to the older version from writing minds, this gave me zero failures.
I spent too much time on it and my project was due. The build runs with android11 well, I set my target sdk to 28.

@kadnan0900
Copy link

@plazar99 but when you upload app on playstore you have to upgrade your tarketsdkversion to 29 thats the major issue.

@mans17312
Copy link

Facing this issue, have any one fixed it so far ?

@mans17312
Copy link

Here is the issue, only for android 10+ devices
Permission denied
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1050)
at java.lang.Runtime.exec(Runtime.java:699)

@SyedSaadUrRehman-MAD
Copy link

bravobits-ffmpeg works for on android 12 with target set to 28, no more permission denied froom ffmpeg after i added "-y" in the start of my every ffmpeg-command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests