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

More Android Scope storage issues #62546

Closed
ondesic opened this issue Jun 30, 2022 · 7 comments
Closed

More Android Scope storage issues #62546

ondesic opened this issue Jun 30, 2022 · 7 comments

Comments

@ondesic
Copy link

ondesic commented Jun 30, 2022

Godot version

3.5 rc5

System information

Windows 11

Issue description

This post is from #51815
It was suggested to start a new thread.
I cannot copy res:// files to the android phone. Still cannot read/write files to Android.

Here are my findings with the included test mono project.
This app is coded to take a file stored in "res://Test/Test.txt" and create a folder named "Test" in the Document folder, then copy the Test.txt file into that folder. When you press the big button, it will read the Test.txt file and assign the string in the file to the button's text.

Steps to reproduce

This runs as expected in Windows. However, on the android device:

  1. if I select "Manage Documents" only, the app will create a "Test" folder but will NOT copy the Test.txt file. I end up with an empty folder.
  2. Next, I uninstall the app and delete the Test folder. I now add "Manage External Storage". The same thing happens, only the Test folder is created with no file inside.
  3. Next I uninstalled and unchecked all permissions. I then only checked "Read External Storage" and "Write External Storage". I got the same results...Test folder created but empty and unable to copy Test.txt to the folder.
  4. Finally, No combination worked except checking all of the following "Manage External Storage", "Read External Storage" and "Write External Storage". Then I have to allow the permissions for "All Files" and then it will finally allow me to copy the Test.txt file..........except...... it makes Test.txt a 0 byte file with nothing inside.

Minimal reproduction project

Here is the project.
TestStorage.zip

side note: I even tried to copy the Test.txt file manually to the Test folder. Pressing the button in the app should read the content but it still won't work.

@akien-mga
Copy link
Member

I seem able to reproduce with 3.5 RC 5 too. I converted the MRP to GDScript as it's easier to work with for debugging, especially when doing custom engine builds to test potential fixes:

TestStorage.zip

Also added a call to OS.request_permissions() otherwise nothing would work for me. I'm not sure what's the usual workflow for permissions / whether the user gets to accept them prior to running the app when installing from a store (doesn't seem to happen over adb).

@ondesic
Copy link
Author

ondesic commented Jul 1, 2022

Usually the user is presented with permission requests when the app is downloaded from store. Not when installing from Godot. I have had to manually approve of each permission in the App Info page. OS.request_permission sounds helpful.

It will be wonderful when this is all fixed

@Summersay415
Copy link
Contributor

Summersay415 commented Jul 4, 2022

I have game with mod support. By default, game should read mods from /Documents/'app ID', but I can't read nothing. Permissions granted.?

As alternate way I can read files from /Android/media/'ID', on 3.5 RC 4 it works fine, but not on RC 5, because engine locks access to that directory.
Android version: 11.

@m4gr3d
Copy link
Contributor

m4gr3d commented Jul 4, 2022

@ondesic @akien-mga I have a fix for the issue in #62719. It was a logic issue and not a permission issue, so the call to OS.request_permission shouldn't be needed on newer versions of Android, but is good to keep for older versions of Android.
On newer versions, it should result in a no-op.

@m4gr3d
Copy link
Contributor

m4gr3d commented Jul 4, 2022

@Summersay415 Your issue is different from the one encountered by @ondesic.

By default, game should read mods from /Documents/'app ID', but I can't read nothing.

If your app created that directory, you should have read/write access to it.
However if it was created by another app, or created by your app, but your app was uninstalled and reinstalled, then you won't have access to that directory.

To get around that restriction you can use the MANAGE_EXTERNAL_STORAGE permission, but bear in mind that permission is restricted if you're targeting the Google Play store.

@Summersay415
Copy link
Contributor

Thanks for information, but how about to allow access to /Android/media/'ID'/? This is app-specific directory.

@akien-mga
Copy link
Member

Fixed by #62719.

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

No branches or pull requests

4 participants