Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot Get External Storage Permissions with Android Custom Build Enabled #60635

Open
gamerrgrilll opened this issue Apr 29, 2022 · 7 comments
Open

Comments

@gamerrgrilll
Copy link

Godot version

3.4.4 Stable

System information

Windows 10, Installing on Android 12.

Issue description

When using the Android permissions READ_EXTERNAL_STORAGE and/or WRITE_EXTERNAL_STORAGE, these permissions are unable to be prompted for, or granted when using a custom Android build.

When using no custom build, with Write External Storage and Read External Storage enabled under the Android Export permissions section, running OS.request_permissions() successfully prompts for the storage permissions, and granting them works perfectly as well.

However, when using a custom build, with the same permissions checked under the Android Export permissions section, running OS.request_permissions() doesn't prompt for the storage permissions, and these storage permissions also do not show under the App Info>Permissions section in Android's settings. Even when manually adding
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
to the custom build's AndroidManifest.xml file, these permissions seemingly cannot be prompted for, or manually granted under App Info.

As a comparison, enabling and prompting for (using OS.request_permissions()) "Read SMS" (android.permision.READ_SMS in the .xml file) successfully prompts, and enables the SMS permissions, even with Android Custom Build enabled, suggesting this issue is only regarding External Storage permissions.

Steps to reproduce

Using the Minimal Reproduction project (which is simply a project with a single button, and "blank"/stock Android custom build template installed), here's how you can replicate this behaviour:

  • Be sure to install an Android Build Template, as it was too large to include in the attatched .zip!

  • Disable Use Custom Build in the Android Export menu.

  • Make sure Read External Storage and Write External Storage are checked under the export "Permissions" section.

  • Enable another permission, such as Read SMS, to be prompted for.

  • Export/Deploy the project onto an Android device. Clicking the button should successfully prompt for both the Storage and SMS permissions.

Uninstall the application from your Android device, so all permissions get revoked.

Then:

  • Enable Use Custom Build in the Android Export menu.

  • Verify Read External Storage and Write External Storage are checked.

  • Verify an additional permission, such as Read SMS, is checked.

  • Export/Deploy the project onto an Android device. Clicking the button should successfully prompt for the SMS permission, but not the Storage permissions.

  • Manually adding or removing storage permission tags to the custom build's AndroidManifest.xml file should not have any effect on whether these permissions are prompted for, or seen under App Info.

Minimal reproduction project

AndroidPermissionTest.zip

@Calinou
Copy link
Member

Calinou commented Apr 29, 2022

Note that Android 11 and later have a scoped storage requirement, so you probably need to include #51815 in a custom build. (This has been a pain point for all application developers lately, not just Godot.)

@gamerrgrilll
Copy link
Author

gamerrgrilll commented Apr 29, 2022

Note that Android 11 and later have a scoped storage requirement, so you probably need to include #51815 in a custom build. (This has been a pain point for all application developers lately, not just Godot.)

Thank you! - I've compiled that build of Godot. I haven't manually compiled Godot before, so I'm wondering where I should source my Export Templates from?

@Calinou
Copy link
Member

Calinou commented Apr 29, 2022

Thank you! - I've compiled that build of Godot. I haven't manually compiled Godot before, so I'm wondering where I should source my Export Templates from?

You need to build your own export templates from the same branch as the one you used to compile the editor. See Compiling for Android for instructions.

@gamerrgrilll
Copy link
Author

Thanks for helping with a topic that you've seen before with others, I appreciate it. - Compiling that build of Godot fixed the issue!

@Calinou
Copy link
Member

Calinou commented Apr 30, 2022

It might be worth leaving this issue open, although we could consolidate this with #48636.

@gamerrgrilll gamerrgrilll reopened this May 2, 2022
@gamerrgrilll
Copy link
Author

It might be worth leaving this issue open, although we could consolidate this with #48636.

Ah, ok! I'll leave it open for now, then,

@finepointcgi
Copy link

finepointcgi commented May 27, 2023

Im currently running into this with Godot 4.0.3

I have read external storage checked
image

I am requesting it
`
func _ready():
OS.request_permissions()
if Engine.has_singleton(plugin_name):
plugin = Engine.get_singleton(plugin_name)
else:
print("Could not load plugin: ", plugin_name)

if plugin:
	plugin.connect("image_request_completed", Callable(self, "_on_image_request_completed"))
	plugin.connect("error", Callable(self, "_on_error"))
	plugin.connect("permission_not_granted_by_user", Callable(self, "_on_permission_not_granted_by_user"))

`

And it seems to not request permission
I also have added it to my custom builds manifest and it still does not work
image

Edit: I pulled open my apk and my manifest does have the permission there
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants