indic-dict / stardict-dictionary-updater

An android app that updates all your Sanskrit Dictionaries from our stardict-* repositories in one shot.
https://sites.google.com/site/sanskritcode/
12 stars 3 forks source link

Access to shared dictdata directory will stop starting Android 12 (maybe) #29

Open kmadathil opened 4 years ago

kmadathil commented 4 years ago

Phone: Moto G Stylus Android Version: 10

Final step displays "Failed on: all files"

Log seems to be unavailable - I cannot share it with email ("Couldn't attach file"), WhatsApp or Bluetooth. I have tried

vvasuki commented 4 years ago

It's odd. I got one or two reports in the past couple of days. Not sure what the problem is. Can't replicate on my phone.

kmadathil commented 4 years ago

I have worked around using a fork of pydictupdater at https://github.com/kmadathil/pydictupdater - updated to work with Python3 and the new repository structure. May be of use to someone else who's similarly stuck. This is a very minimal python solution; it requires you to know how python works, and have a passing familiarity with the structure of indic-dicts, so it is not a sufficient workaround for a general user.

vvasuki commented 4 years ago

@kmadathil - I've made you maintainer of https://github.com/sanskrit-coders/pydictupdater and given you write access to this repo. Can you merge back your changes there (and perhaps even debug this repo for your case)?

kmadathil commented 4 years ago

I've merged my pydictupdater changes. It can be improved if someone actually shows interest in using it.

vvasuki commented 4 years ago

@kmadathil Can you update to 3.4.5 (should be out tomorrow), rerun, and send me the log (final button)?

kmadathil commented 4 years ago

Done. You should have the log in your mailbox

vvasuki commented 4 years ago

Done. You should have the log in your mailbox

11-05 20:31:49.570 22797 22797 E ArchiveDownloader: java.lang.AssertionError: Cannot create parent directories for requested File location
...
11-05 20:31:49.570 22797 22797 E ArchiveDownloader:     at sanskritCode.downloaderFlow.ArchiveDownloader$downloadArchive$1.<init>(ArchiveDownloader.kt:67)

Strange - why can't it create the parent directories while downloading? Luckily I can replicate it with a simulated android 10 device. Will look into it.

kmadathil commented 4 years ago

My previous device was Android 10 as well, but it may have been upgraded from 9 to 10 after the first download. It is likely then that directory creation is the root cause.

vvasuki commented 4 years ago

Problem is that from Android 10, an app cannot have direct access to arbitrary shared directories. Instead, app needs to let the user pick a directory via "Storage Access Framework", or "provide" files of a certain mimetype. I am not sure how various dict apps will adjust to this (probably not a big deal since they need mostly read access) - but will wait and see.

Short term solution

For now, I've just postponed the problem to Android 12.

As https://stackoverflow.com/questions/58379543/cant-create-directory-in-android-10 says:

For Android 10 and 11, you can add android:requestLegacyExternalStorage="true" to your element in the manifest. This opts you into the legacy storage model, and your existing external storage code will work.

The temp fix should roll out to production in a day or two.

Long term solution

Copying 100s/ 1000s of files to user-selected external directory via "Storage Access Framework" will be quite irritating - hopefully someone will publish a good code snippet in the next year.

If that does not work, I will consider just junking this app and going the python route (those poor users who are not tech-savvy will unfortunately have to get by).

vvasuki commented 4 years ago

" temporarily opt out of the changes associated with scoped storage " says https://developer.android.com/training/data-storage/use-cases#opt-out-scoped-storage . No idea when the blade will fall - may be later than android 12.