No Permissions Requested from Android Export Custom Build

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By dagrooms52

Versions: Godot 3.5.1, Android 12

I have checked the “Internet” and “Access Network State” options in the Export configuration for an Android APK export of my Godot project. When I check the AndroidManifest.xml, the typical <uses-permission ... /> tags are not present. When I install the APK on a phone, the App Info page says “No Permissions Requested.”

How can I tell if this is a Godot bug or get it working? Is there a manual workaround? Even if I add a <uses-permission ... /> tag in the AndroidManifest.xml, the app still says “No Permissions Requested” in App Info. It seems like there is no way to change the permission state of my app.

Did you ever solve this? I’m stuck on the same issue atm
My app works on the emulator just fine, but on a real phone it just says no permissions granted. It never auto requests. I’ve found here that one needs to manually trigger permissions requests for the phone, but how do you do that with godot?

Dumuz | 2023-04-08 19:20

:bust_in_silhouette: Reply From: krkl

So, I ran into the same problem and managed to extract some information from the discussion of related github issues. I found that we have an interesting combination of two problems. It is correct that recent Androids require you to request special permissions at runtime and OS.request_permissions() does just that. It also checks whether the required permissions have already been granted and stays silent if that’s the case. You can just put in your main _ready() function and it’s there for you.

The scenario that you put permission requests in your manifest, and OS.request_permissions() doesn’t do shit arises when the requested permissions are not part of the ones used by the targeted Android version. IIRC READ/WRITE_EXTERNAL_STORAGE has fallen out of usage with Android 10 and has been replaced by

  1. A Set of directories that are r/w accessible to everyone (e.g. …/Download). There may be others and even some that are owned by your app but hidden from the device owner.
  2. Several new permissions that are connected to file types (MANAGE_MEDIA_FILES or something similar)

This means that you have to request all plausible combinations of required permissions for all targeted Android versions but only the ones relevant to the installed one will be requested. Which permissions are required for what is hidden deep within the Android docs and tends to change with each sdk version.