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

IMPORTANT: Changes to /sdcard/lovegame Functionality #194

Closed
MikuAuahDark opened this issue Oct 1, 2020 · 23 comments · Fixed by #195
Closed

IMPORTANT: Changes to /sdcard/lovegame Functionality #194

MikuAuahDark opened this issue Oct 1, 2020 · 23 comments · Fixed by #195
Labels
change Change to existing functionality
Milestone

Comments

@MikuAuahDark
Copy link
Collaborator

MikuAuahDark commented Oct 1, 2020

When you try to run LOVE Android compiled at f0abf9b, and you're using the "normal" or "playstore" flavor, and you want to run games from /sdcard/lovegame, you'll see this error.

Turns out this is caused by Android 10 scoped storage restictions. It's possible to opt-out for this change but then Android 11 will force it for all apps that targets API 30 and later.

Sadly this mean the only possible solution is to move /sdcard/lovegame to somewhere else like /sdcard/Android/data/org.love2d.android/games/lovegame. Unfortunately even with this change, apps inside the phone won't able to access that directory at all and the only way to access those directories is by plugging the phone to the computer. This is breaking change but this is also inevitable.

That behavior is basically how LOVE iOS behaves, according to slime explanation in Discord. If this gonna end up like LOVE iOS, then I may have reason to develop game selector for LOVE 12.0.

TL;DR: /sdcard/lovegame no longer works in Android 10 and later and will be moved to /sdcard/Android/data/org.love2d.android/files/games/lovegame.

This issue will be closed once I moved the directories. Any suggestion or critism is welcome.

EDIT: To provide backward compatibility at some extent, LOVE will also look at /sdcard/lovegame in Android 9 and earlier.

@MikuAuahDark MikuAuahDark added the change Change to existing functionality label Oct 1, 2020
@MikuAuahDark MikuAuahDark pinned this issue Oct 2, 2020
MikuAuahDark added a commit to MikuAuahDark/love2d-android that referenced this issue Oct 2, 2020
See love2d#194

This also mean that external storage permission is only requested only when running Marshmallow or earlier.
MikuAuahDark added a commit that referenced this issue Oct 6, 2020
@MikuAuahDark MikuAuahDark changed the title IMPORTANT: Changes To /sdcard/lovegame IMPORTANT: Changes to /sdcard/lovegame Oct 6, 2020
MikuAuahDark added a commit that referenced this issue Oct 9, 2020
* Update dependencies and target SDK
* Update Gradle to 6.6.1
* Update target API level to 30
* Update AGP to 4.0.1
* Update Android Build Dependencies (androidx.appcompat:appcompat:1.2.0, androidx.multidex:multidex:2.0.1)
* Update readme
* Move /sdcard/lovegame directory. (closes #194)
* Potentially fixes black screen when reopening LOVE from app drawer (fixes #190)
* Downloader cleanup.
* Merge SDL AndroidManifest.xml to LOVE
* Implement partial "Share to LOVE" support.
* Enable resizeableActivity
MikuAuahDark added a commit that referenced this issue Dec 25, 2020
…mpatibility.

See #194 for further explanation about this change.
@MikuAuahDark MikuAuahDark changed the title IMPORTANT: Changes to /sdcard/lovegame IMPORTANT: Changes to /sdcard/lovegame Functionality Jan 16, 2021
@MikuAuahDark MikuAuahDark added this to the 11.4 milestone Nov 22, 2021
@Vixeliz
Copy link
Contributor

Vixeliz commented Dec 27, 2021

Is this changed in main? Also why did you say other apps can't access that directory? They can

@MikuAuahDark
Copy link
Collaborator Author

MikuAuahDark commented Dec 28, 2021

Yes. This changes has been in main branch. Other apps can't access Internal Storage/Android/data except their own Internal Storage/Android/data/package.name directory and it's enforced in Android 11 https://developer.android.com/about/versions/11/privacy/storage#other-apps-data

@Vixeliz
Copy link
Contributor

Vixeliz commented Dec 28, 2021

Strange something must be wrong with my tablet then on android 11 using material files I can access android/data files just fine of other apps. Just tested on my phone appears it doesn't work there strange

@Vixeliz
Copy link
Contributor

Vixeliz commented Dec 28, 2021

Out of curiosity what stops love2d with external access to read files to use for the game?

@Vixeliz
Copy link
Contributor

Vixeliz commented Dec 28, 2021

Sorry for the questions I use android as my main computer so these changes are concerning for my workflow. If you don't want to spam this github issue is there anywhere I can dm you?

@MikuAuahDark
Copy link
Collaborator Author

I'm not quite sure what do you mean, but if you read my writings on top of this issue, you should be able to know why.

Please let me know if something's not clear about it.

@Vixeliz
Copy link
Contributor

Vixeliz commented Dec 28, 2021

I somewhat understand I've read about scoped storage changes however what I don't understand is apps can still access /sdcard so why can't they run the lua files since the interpreter itself is in the apk. Sorry I'm pretty dumb just a little confused

@MikuAuahDark
Copy link
Collaborator Author

File Managers are allowed to access /sdcard with MANAGE_EXTERNAL_STORAGE permission in Android 11 and later, or using legacy non-scoped storage in Android 10. However, we can't easily gives LOVE a MANAGE_EXTERNAL_STORAGE permission because Google Play has strong enforcement on what kind of apps are allowed to have such permissions.

@Vixeliz
Copy link
Contributor

Vixeliz commented Dec 28, 2021

What if we were to have two versions a fdroid/github one and a Google play one?

@Vixeliz
Copy link
Contributor

Vixeliz commented Dec 28, 2021

Or even a define flag somewhere? I'm sure most people using love on android in a non emvedded way wouldn't mind installing outside of Google play

@MikuAuahDark
Copy link
Collaborator Author

We already have GitHub and Google Play variants. The Google Play variants doesn't support audio recording while the GitHub variant supports it. I plan to distribute for F-Droid but I was too busy to setup the repository such that it's F-Droid compatible.

Anyway, MANAGE_EXTERNAL_STORAGE is a privacy concerning permission. No wonder Google has strong use-case enforcemenet on that permission. Any reason why you're against on moving the location?

While writing this, it seems I break this change, so I'm now debugging it.

@Vixeliz
Copy link
Contributor

Vixeliz commented Dec 28, 2021

I use android as my main dev environment so zipping up the files everytime to debug my game or compiling everytime(through termux) is annoying to say the least. Where as I can have live reload if it's in /sdcard/love game. I know it's a privacy concern but for me to just debug it would be nice. I'm testing out the permission right now

@MikuAuahDark
Copy link
Collaborator Author

MikuAuahDark commented Dec 28, 2021

I use android as my main dev environment

Well, developing LOVE games in Android is never a supported scenario at all, so you're on your own.

@Vixeliz
Copy link
Contributor

Vixeliz commented Dec 28, 2021

Yeah fair enough I'll see if I can't just edit the source code myself. Really doubting my decision to use android lol thx for the tips on the file manager thing though maybe it'll help me out.

MikuAuahDark added a commit that referenced this issue Dec 28, 2021
@Vixeliz
Copy link
Contributor

Vixeliz commented Dec 28, 2021

Also just wondering if android isn't supported why make a game selector?

@MikuAuahDark
Copy link
Collaborator Author

MikuAuahDark commented Dec 28, 2021 via email

@Vixeliz
Copy link
Contributor

Vixeliz commented Dec 28, 2021

One last question. I know I won't get any support but if you know it's a simple question. Using MANAGE_EXTERNAL_STORAGE if I can figure out how to do it myself should I be able to get it to read from /sdcard/lovegame?

@MikuAuahDark
Copy link
Collaborator Author

MikuAuahDark commented Dec 28, 2021 via email

@Vixeliz
Copy link
Contributor

Vixeliz commented Dec 28, 2021

Alright thank you. I tried to figure it out but I'm not familiar with android dev so I may try to find an alternative solution thanks for answering questions even though it's unsupported

@Vixeliz
Copy link
Contributor

Vixeliz commented Dec 28, 2021

I do have one last question I swear this is the last one. Why do you have no interest in supporting android as a dev environment right now love is one of the few options there is for android game dev. I am going to try to fork the love-android repo with some minimal changes to hopefully make it more possible to do so. But from what I understand there is no interest to accept said changes to master even as options?

@MikuAuahDark
Copy link
Collaborator Author

Because using Android as development is (probably) never a supported scenario in general(?) (i.e. Google doesn't intend us to use Android as developing environment).

You see, Android was used to allow any files access. However due to privacy concern, in Android 6, apps must ask user for such external storage access. Then further, using file:// URI is banned in Android 7, causing .love file association to stop working. More restriction are in place in Android 9 by start limiting what actions you can do in /sdcard/Android/data folder. Eventually in Android 10, scoped storage comes in that restricts access to anywhere, but they know that apps may not ready for that change yet. Then in Android 11, they enforce the previous scoped storage and fully restrict access to /sdcard/Android/data.

Of course they realize that user may need to access /sdcard/Android/data, thus there's 2 way to access it:

  1. Using the Android built-in file manager. No, this is not your vendor-provided file manager nor Google's Files.
  2. Using MTP by connecting your phone to your PC.

@Vixeliz
Copy link
Contributor

Vixeliz commented Jun 1, 2022

If anyone is reading this since this is pinned if the pr #230 get's accepted this will be a non issue as any apps that support android's storage access framework will allow love files to be edited again.

@Hellscaped
Copy link

Because using Android as development is (probably) never a supported scenario in general(?) (i.e. Google doesn't intend us to use Android as developing environment).

You see, Android was used to allow any files access. However due to privacy concern, in Android 6, apps must ask user for such external storage access. Then further, using file:// URI is banned in Android 7, causing .love file association to stop working. More restriction are in place in Android 9 by start limiting what actions you can do in /sdcard/Android/data folder. Eventually in Android 10, scoped storage comes in that restricts access to anywhere, but they know that apps may not ready for that change yet. Then in Android 11, they enforce the previous scoped storage and fully restrict access to /sdcard/Android/data.

Of course they realize that user may need to access /sdcard/Android/data, thus there's 2 way to access it:

  1. Using the Android built-in file manager. No, this is not your vendor-provided file manager nor Google's Files.
  2. Using MTP by connecting your phone to your PC.

Actually, there is a third option.
There is a file explorer that can read and write to those directories. Its called ZArchiver. It uses SAF to read the android/data dir. When you go to the dir for the first, it opens up the built in file manager, and prompts you to press "use this folder". Doing so lets you access all contents of android/data

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

Successfully merging a pull request may close this issue.

3 participants