cordova-plugin-android-permissions icon indicating copy to clipboard operation
cordova-plugin-android-permissions copied to clipboard

[feature-request] Add <uses-permission> to manifest for each requested permission

Open iakanoe opened this issue 4 years ago • 4 comments

When trying to request some permission, if it is not declared on AndroidManifest.xml, Android will not even try to request it and directly return false when checking. I solved this temporally by adding this code on config.xml, maybe it can be added automatically. <config-file parent="/manifest" target="AndroidManifest.xml"> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-feature android:name="android.hardware.microphone" /> </config-file>

iakanoe avatar Mar 15 '20 22:03 iakanoe

Thanks you made my day!

numerized avatar Mar 16 '20 09:03 numerized

If someone has problems with android namespace, just put this in <widget> as a property so the xml is valid:

xmlns:android="http://schemas.android.com/apk/res/android"

vladoski avatar Jun 20 '20 16:06 vladoski

I agree that the plugin only asks for permissions declared with <uses-permission>, but doesn't this defeat the use of the plugin?

I'm not an Android expert, but isn't the whole point to avoid <uses-permission> for runtime permissions?

After all, also the Android guide describes <uses-permissions> as problematic:

image

Also, when publishing an app via the Play Console such permissions are listed as "required":

image

...however I need these sensitive permissions only in certain rare situations and the user should not need to grant these permissions on install.

Edit: Google Play Console also won't publish the app to devices that do not support permissions listed in <uses-permission> unless <uses-feature android:required="false" .../> is added.

Am I missing something?

jampy avatar Jan 19 '22 10:01 jampy

@jampy As the docs say:

Beginning with Android 6.0 (API level 23), the user can approve or reject some app permisions at runtime. But no matter which Android version your app supports, you must declare all permission requests with a <uses-permission> element in the manifest. If the permission is granted, the app is able to use the protected features. If not, its attempts to access those features fail.

All runtime permissions must be declared in the manifest to be able to ask for them to be granted at runtime.

iakanoe avatar Feb 21 '22 22:02 iakanoe