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

Game only seeing files created by Godot itself on Android #91911

Closed
Swarkin opened this issue May 13, 2024 · 6 comments
Closed

Game only seeing files created by Godot itself on Android #91911

Swarkin opened this issue May 13, 2024 · 6 comments

Comments

@Swarkin
Copy link
Contributor

Swarkin commented May 13, 2024

Tested versions

v4.3.dev6.official [89850d5]

System information

Android 13 - Samsung Galaxy S20 FE 5G

Issue description

Files do not show up, likely a permissions problem but I was unable to find any related permissions regarding the file system.
There aren't any permissions listed in the settings for the app.

Steps to reproduce

func _ready() -> void:
	# /storage/emulated/0/Documents contains several files.
	DirAccess.get_files_at("/storage/emulated/0/Documents")  # []
	FileAccess.open("/storage/emulated/0/Documents/text.txt", FileAccess.WRITE).close()
	DirAccess.get_files_at("/storage/emulated/0/Documents")  # ["test.txt"]

Minimal reproduction project (MRP)

any

@Swarkin Swarkin changed the title Android only seeing files created by Godot itself Game only seeing files created by Godot itself on Android May 13, 2024
@tiloc
Copy link

tiloc commented May 13, 2024

Android is very limiting with access to arbitrary files since Android 11. https://developer.android.com/about/versions/11/privacy/storage

If you request the permission to do this, then you won't be able to publish to Play Store, unless you happen to be a file management app.

@Swarkin
Copy link
Contributor Author

Swarkin commented May 13, 2024

I dont quite understand where I request these?
From the android docs: To disable scoped storage and use the legacy storage model instead, unset both flags.
But the DEFAULT_SCOPED_STORAGE flag is greyed out and always active in the compatibility settings,

@tiloc
Copy link

tiloc commented May 13, 2024

I dont quite understand where I request these? From the android docs: To disable scoped storage and use the legacy storage model instead, unset both flags. But the DEFAULT_SCOPED_STORAGE flag is greyed out and always active in the compatibility settings,

Android will not allow you to use legacy storage anymore, regardless of what you request, unless you intentionally want to run only on old phones (Android 11 and older). You need to rework your app to only require access to your own files, or use Android APIs for media access, photo access etc.

@Swarkin
Copy link
Contributor Author

Swarkin commented May 14, 2024

Is it possible to make Godot request the all files permission, like the Editor does?

@tiloc
Copy link

tiloc commented May 14, 2024

Is it possible to make Godot request the all files permission, like the Editor does?

See my link above. Google would most likely not permit the publication of your app then. See https://developer.android.com/training/data-storage/manage-all-files#all-files-access-google-play for specific details.

@Swarkin
Copy link
Contributor Author

Swarkin commented May 14, 2024

Thanks, got it working by enabling MANAGE_EXTERNAL_STORAGE in the build config and running OS.request_permissions().
Closing as it is not a Godot issue

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