cordova-plugin-media-capture icon indicating copy to clipboard operation
cordova-plugin-media-capture copied to clipboard

Android permission denied When opening the camera

Open tamsel12 opened this issue 1 year ago • 3 comments

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

tamsel12 avatar Oct 13 '22 07:10 tamsel12

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]

tamsel12 avatar Oct 15 '22 06:10 tamsel12

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 avatar Oct 17 '22 16:10 breautek

@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.

tamsel12 avatar Oct 19 '22 09:10 tamsel12

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

tamsel12 avatar Oct 22 '22 13:10 tamsel12

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 

tamsel12 avatar Oct 27 '22 10:10 tamsel12