cordova-plugin-media-capture
cordova-plugin-media-capture copied to clipboard
Android permission denied When opening the camera
I have updated the SDK version 32 in Android application and Updated the plugin too.
Before It works fine , It captures the image and video fine. Now After Upgrading SDK version, Camera not opened and it throws as "Permission Denied" error.
What is expected to happen?
After Upgrading the version 32 cordova-android 11 , it should open camera
What does actually happen?
Camera not opening, It throws Permission Denied error {"code":4,"message":"Permission denied."} vendor-es2015.js:41296 ERROR Error: Uncaught (in promise): Object: {"code":4,"message":"Permission denied."} at resolvePromise (polyfills-es2015.js:3904:39) at resolvePromise (polyfills-es2015.js:3856:21) at polyfills-es2015.js:3966:21 at ZoneDelegate.invokeTask (polyfills-es2015.js:3505:35) at Object.onInvokeTask (vendor-es2015.js:64523:33) at ZoneDelegate.invokeTask (polyfills-es2015.js:3504:40) at Zone.runTask (polyfills-es2015.js:3273:51) at drainMicroTaskQueue (polyfills-es2015.js:3675:39)
Information
Updated the Cordova-android 10 to cordova-android 11 which targets 32
Command or Code
ionic cordova run android --device
Environment, Platform, Device
This issue in Android Device [Checked in Android 10, Android 11, Android 12]
Version information
Android version [10,11,12] Cordova-android 11[sdk -32] Mediacapture plugin 4.0.0
Checklist
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
Any Solutions? We want to upload the Build with targetSDKLevel 32 within October to playstore. From november onwards playstore will only accept the SDK Level above 30. This plugin works fine in Android SDK 30 [Cordova-android-10]
Android has the capability of automatically rejecting permissions if the user has previously "Denied Always" permission in the past and this information can survive app uninstalls/reinstalls. In which case, the user must change permissions using the Android App settings.
Are you certain this isn't the case of a permission being denied always? On AOSP emulators, you can reset this state using adb shell pm reset-permissions
which is useful for testing. You'll need to have $ANDROID_HOME/platform-tools
in your PATH
to use the adb
command.
Note that this command will reset permissions on *all* applications back to their default "Not requested" state for all permissions, but I don't think this command is available on Google android images (images with the playstore) or real devices.
@breautek I have not run on Emulator, I tested in Android device , the same version is working fine on SDK 30 level on Android Devices , But after upgrading to 32 [cordova-android 11] only , this permission issue arises.
This issue arises when using Mediacapture plugin with latest instabug-cordova plugin. I have checked media capture plugin alone, it opens the camera and it works fine but with latest Instabug-cordova plugin only its throwing the permission denied error
Actually Below fixes the problem -- Remove instabug-cordova and readd the plugin -- Update in Android manifest file
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:remove="android:maxSdkVersion"
-- Update
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.yourpackage" xmlns:tools="http://schemas.android.com/tools">
Now its working fine for me, I will close this issue
Why this problem?
I'm using ionic 6 (capacitor 5) and i've faced this problem due to Android 13 permissions changes.
What I've done?
I've found e temporary solutions for those who needs only a working captureVideo()
method as me.
Check out the fork here:
https://github.com/SocialCities/cordova-plugin-video-capture
Basically I've added a version check method to support Android 13 (SDK >= 33) permissions changes as you can see here:
https://github.com/apache/cordova-plugin-media-capture/compare/master...SocialCities:cordova-plugin-video-capture:master.
In particular I've added READ_MEDIA_VIDEO
permission requirement dynamically if SDK is >= 33).
How to install?
// uninstall cordova-plugin-media-capture
npm uninstall cordova-plugin-media-capture
// install my fork
npm install https://github.com/SocialCities/cordova-plugin-video-capture.git
// if it's not already done:
npm install @awesome-cordova-plugins/media-capture
ionic cap sync
Attention
This solutions is incomplete. Plugin's methods other than captureVideo()
should not works correctly, because i have an upcoming work deadline and I need only that method.
If you need the other plugin's methods too, you need to extend my function and manage the other permissions requirements for version SDK >= 33 (READ_MEDIA_IMAGES
and READ_MEDIA_AUDIO
) based on what needed.
Hope this fork can be useful for those who need a temporary solution like me 😺!
I tried with your fork I am getting class not found an error in android API 31.
I'm using API 33 ionic 6 (capacitor 5). With API 31 you will probably have problems on every device with Android 13 (due to Android 13 permissions changes).
I am using Ionic 7 and I get the canceled issue right after accepting the permission to use camera. Any workaround or anyone else knows what this is caused by?
I tried with your fork I am getting class not found an error in android API 31.
me too ,can had you sloved it?