Closed drahuks closed 1 month ago
Ok, I see there is a conflict between the camera storage permission selection in Diagnostic_Camera.java:
protected static String[] storagePermissions; static { if (android.os.Build.VERSION.SDK_INT >= 33) { // Build.VERSION_CODES.TIRAMISU / Android 13 storagePermissions = new String[]{ "READ_MEDIA_IMAGES", "READ_MEDIA_VIDEO" }; } else { storagePermissions = new String[]{ "READ_EXTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE" }; } }
and the permission max SDK check in Diagnostic.java:
`/**
Map of maximum build SDK version supported by defined permissions */ protected static final Map<String, Integer> maxSdkPermissionMap; static { Map<String, Integer> _permissionsMap = new HashMap <String, Integer>();
Diagnostic.addBiDirMapEntry(_permissionsMap, "READ_EXTERNAL_STORAGE", 32);
Diagnostic.addBiDirMapEntry(_permissionsMap, "WRITE_EXTERNAL_STORAGE", 29);
maxSdkPermissionMap = Collections.unmodifiableMap(_permissionsMap);
}`
So devices running SDK 30/31 will request WRITE_EXTERNAL_STORAGE but permission request will throw an error as current SDK is not compatible
@drahuks how did you solve this? We are facing the same issues on Android 11 devices
@mirko77
You need to edit the plugin source code Diagnostic.java, line 190:
Diagnostic.addBiDirMapEntry(_permissionsMap, "WRITE_EXTERNAL_STORAGE", 29);
Set api level 32 instead of 29
This should be fixed in plugin v7.2.0 which was just published
Bug report
Current behavior:
I have an ionic 7/cordova (12.0.0) application using cordova-plugin-camera 7.0.0 and cordova-diagnostic-plugin 7.1.4
App is built with android-targetSdkVersion=33
I manage permissions using diagnostic plugin before calling camera plugin, using getCameraAuthorizationStatus/requestCameraAuthorization. I need the storage permission as I want to save taken pictures to user Photo Album
I get error reports from users running app on Android 12 that are not able to take pictures The requestCameraAuthorization call gives following error :
From my readings I got that theREAD/WRITE_EXTERNAL_STORAGE permissions were not effective anymore starting from sdk 33, but that they were still accepted in lower versions. That's what is done in the permission plugin source code
Is there something I am doing wrong here?
Thanks for helping me understand this behaviour...
Expected behavior: Permissions should be handled well in android 12
Environment information
Cordova CLI version 12.0.1
Cordova platform version android 12.0.1
Plugins & versions installed in project (including this plugin) com.darktalker.cordova.screenshot 0.1.5 "Screenshot" cordova-android-play-services-gradle-release 4.0.0 "cordova-android-play-services-gradle-release" cordova-background-geolocation-lt 4.16.3 "BackgroundGeolocation" cordova-plugin-advanced-http 3.3.1 "Advanced HTTP plugin" cordova-plugin-android-notch 1.0.0 "AndroidNotch" cordova-plugin-android-permissions 1.1.5 "Permissions" cordova-plugin-androidx-adapter 1.1.3 "cordova-plugin-androidx-adapter" cordova-plugin-app-version 0.1.14 "AppVersion" cordova-plugin-background-fetch 7.2.4 "CDVBackgroundFetch" cordova-plugin-battery-status 2.0.3 "Battery" cordova-plugin-camera 7.0.0 "Camera" cordova-plugin-device-orientation 3.0.0-dev "Device Orientation" cordova-plugin-device 2.1.0 "Device" cordova-plugin-file 8.0.1 "File" cordova-plugin-firebase-analytics 8.0.0 "FirebaseAnalyticsPlugin" cordova-plugin-firebase-dynamiclinks 8.0.0 "FirebaseDynamicLinksPlugin" cordova-plugin-firebasex 16.5.0 "Google Firebase Plugin" cordova-plugin-fullscreen 1.3.0 "cordova-plugin-fullscreen" cordova-plugin-geolocation 4.1.1-dev "Geolocation" cordova-plugin-inappbrowser 6.0.0 "InAppBrowser" cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard" cordova-plugin-ionic-webview 5.0.0 "cordova-plugin-ionic-webview" cordova-plugin-media-capture 5.0.0 "Capture" cordova-plugin-nativeaudio 3.0.9 "Cordova Native Audio" cordova-plugin-network-information 3.0.0 "Network Information" cordova-plugin-pedometer 0.4.1 "Core Motion Pedometer" cordova-plugin-splashscreen 6.0.2 "Splashscreen" cordova-plugin-statusbar 4.0.0 "StatusBar" cordova-plugin-vibration 3.1.1 "Vibration" cordova-plugin-video-editor 1.1.3 "VideoEditor" cordova-plugin-x-socialsharing 6.0.4 "SocialSharing" cordova-save-image-gallery 0.0.27 "saveImageGallery" cordova-support-android-plugin 2.0.4 "cordova-support-android-plugin" cordova.plugins.diagnostic 7.1.4 "Diagnostic" es6-promise-plugin 4.2.2 "Promise" phonegap-plugin-barcodescanner 8.1.0 "BarcodeScanner"
Dev machine OS and version, e.g. Windows 11
Runtime issue
Android build issue:
Related code:
Console output
console output
``` (error:Exception occurred: Permission WRITE_EXTERNAL_STORAGE not supported for build SDK version 31) ```**Other information:** none