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

Download fails due to permission problems #308

Closed
Araucarier opened this issue Oct 31, 2017 · 26 comments
Closed

Download fails due to permission problems #308

Araucarier opened this issue Oct 31, 2017 · 26 comments

Comments

@Araucarier
Copy link

Yalp Version

YalpStore 0.28

Expected behaviour

After logging in and search for app updates you click on an app with available updates. After that you click the download button. The download should start and you should be able to install the application afterwards.

Actual behaviour

Instead of downloading the application I get a pop up message, that says: "could not create folder or it is not writable" (translated to english).

Steps to reproduce

  1. Log in to with fake yalp credentials
  2. Update application list (search for updates)
  3. click on any app with new updates
  4. click on the download button
  5. You are asked (if yalp store is freshly installed) to grant access to the storage
  6. You grant access to the storage
  7. Download fails, because location is not writable

Info about your device

Galaxy S3 (i9300) with Lineage OS 14.1 (20170913-NIGHTLY-i9300).

If I look in the privacy protection settings in the settings of android and select Yalp store, I can see, that the change of settings was one time denied, although I definitely clicked on granting access to the storage. I tried it 3 times with a freshly installed yalp store and I always have the same beaviour.

@yeriomin
Copy link
Owner

yeriomin commented Nov 3, 2017

Thanks for writing.

This problem exists, judging by the bug reports submitted from the app. But I never could reproduce it.

Yalp Store puts downloaded files into <external storage>/Download by default. You can see the specific path in the settings. Is it properly created on your device? Does it have any non-default permissions? Maybe changing the download directory in the settings will help.

Meanwhile I've added some additional logging.

@Araucarier
Copy link
Author

Araucarier commented Nov 3, 2017 via email

@sky321
Copy link

sky321 commented Nov 9, 2017

I have had exactly the the same problem with my S2 I9100 wich share a lot of code with the S3 I9300 on LineageOS. One workaround for me fixed it.
Go to developer options and use the „external storage usage allow for apps“ option in the last section (Apps). Sorry just the german translation, don‘t know how it spell in the english version.

@IzzySoft
Copy link

IzzySoft commented Nov 12, 2017

@yeriomin Maybe you could use a file picker instead of the text input, so it pops up the corresponding DocumentProvider dialog? That way the system should give the permission if the user confirms. Currently it's not even possible to specify a path on a different storage, as the "prefix" seems to be fixed. So I cannot install anything via Yalp at the moment, and there are several updates pending …

@sky321 I'm using LOS as well (LOS 13/Android 6.0.1 – the latest one available for my device), but unfortunately couldn't find that option there.

PS: Found another workaround, using the Marshmallow SD fix Xposed module and whitelisting YalpStore (just mentioning it as it might be helpful to other affected users until it's fixed).

@pcercuei
Copy link

Affects me as well (S2 i9100, Lineage OS 14.1).

@Araucarier
Copy link
Author

Hey there,

at least for me the version 0.29 fixed my problem. It was no work around needed. Can anybody confirm that?

@IzzySoft
Copy link

@Araucarier Not me. That was what I was playing with and only got working via the mentioned Xposed module.

@pcercuei
Copy link

This is with version 0.29 here too and the bug is there. I worked around it by making it a system app.

@yeriomin
Copy link
Owner

Asking the user for the permission at first launch, before anything else, might help. That would be easy to implement, but is against android guidelines...

@Araucarier
There were no changes that could fix this in 0.29, unfortunately.

@IzzySoft

Maybe you could use a file picker instead of the text input

I've looked into this option before adding the download directory choice. The components I've found would, if used, double the apk size and make Yalp Store incompatible with old androids.

@IzzySoft
Copy link

@yeriomin

Asking the user for the permission at first launch, before anything else, might help. That would be easy to implement, but is against android guidelines...

Am I getting something wrong here? To me that sounds like meeting the "permissions on demand". For comparison: when setting up Titanium Backup one has to pick a directory as well. That requests DocumentProvider then to grant access to the chosen directory (which the user has to confirm). As this is only needed with Android 5+, it should of course only happen then.

The components I've found would, if used, double the apk size and make Yalp Store incompatible with old androids.

Both very valid reasons against, agreed. I'm no Android dev; but isn't there an intent that could be called for picking a directory, where "registered components" (such as file managers) would respond to? That'd of course leave the question what happens if there's no file manager installed. I don't know either if there's a "standard Android component" for that it could default to.

@Araucarier
Copy link
Author

@yeriomin OK, but it still works for me now. Maybe because I updated the app from 0.28 to 0.29? I did not change anything else...

@IzzySoft
Copy link

@Araucarier I've also updated from 0.28 (installed from a backup, as the device was just completely reset and flashed fresh) to 0.29. Only after that I'd noticed the problem. Didn't have it with 0.28 (on Android 5), just with 0.29 (on Android 6).

@IzzySoft
Copy link

@yeriomin this sounds like what you might want give a try. Quoting the start:

Interacting with the new APIs in Lollipop is very similar. To prompt the user to pick a directory tree, you can launch an intent like this:

Then some code follows. Though it says Lollipop, it's worth a try for multiple reasons: it might solve the issue some of us are having – and it gives you a "directory picker" (at least it sounds like) without the need to include another library.

Could you give this a look? Thanks in advance!

@curiousrom
Copy link

curiousrom commented Nov 21, 2017

Galaxy S3 (i9300) with Lineage OS 14.1 (20171117-NIGHTLY-i9300). YalpStore 0.30 excluded from Privacy Guard.

I got the same error as the OP multiple times
: "Instead of downloading the application I get a pop up message, that says: "could not create folder or it is not writable"

Also in Yalp > Your apps > selecting an app > Get local apk would say "Saved in your Downloads folder" but nothing was downloaded in the Download folder.

In YalpStore > Settings > Download directory it says the default is > /storage/emulated/0/Download when pressing on it the only option is to change the name of the Folder & not the path. I killed Yalp & created a new folder in /storage/emulated/0/ and in Yalp changed the destination folder name in Settings > Download directory but still got the same error. Changed it back to Download which already existed before installing Yalp Store with all the correct read/write folder permissions, same error.

After reading this post above from @yeriomin

Yalp Store puts downloaded files into "external storage"/Download by default.

So I killed Yalp & created a Download folder in the root of my external SD card, did not changed the > Settings > Download directory in Yalp & I can now download apk's in /storage/emulated/0/Download. I don't know why it fixed the problem but it now works.

screenshot_20171121-013958

screenshot_20171121-015222

@yeriomin
Copy link
Owner

@IzzySoft

it might solve the issue some of us are having

It won't. The issue is: the permission is granted by the user, but writing is still denied by the OS. At best it will not show the non-writable directories, and most likely it will just let you choose the same thing the current solution does.

Directory picker vs a plain string preference is not the point of this issue.

Still, I'll look into it, thanks.

@monteverde-org

Changed it back to Download which already existed before installing Yalp Store with all the correct read/write folder permissions, same error.
So I killed Yalp & created a Download folder in the root of my external SD card... I don't know why it fixed the problem but it now works.

So you didn't actually change the default path? Where are the apks saved?

created a Download folder in the root of my external SD card

What is its absolute path?

@IzzySoft @Araucarier @pcercuei @sky321 It appears you all have Samsung devices with a SD card slot. Am I right? If yes, does @monteverde-org 's solution work for you?

I'm starting to think the important thing in this workaround is to kill Yalp, and after the OS starts a different process for it, the permission is granted properly...

the only option is to change the name of the Folder & not the path.

Actually, its any path as long as it is on your device's external storage. Note, that the name "external storage" is historical. Even if the device has no SD-card slot, the OS calls the place where all the user-accessible stuff is situated "external". https://developer.android.com/guide/topics/data/data-storage.html#filesExternal

@IzzySoft
Copy link

@yeriomin I've never used a Samsung phone (and am unlikely to do so in the near feature at least) – but yes, internal + external SD are present. I currently cannot test whether the work-around presented by @monteverde-org works (that would require multiple boots as I had to disable it in the Xposed module – and I'm currently performing a "long term" stability test for some other app). I could check, though, if there's a Download directory in both locations (assuming Yalp checks on one and then writes to the other) – but AFAIR I already had verified there is.

Side note: It might well be a bug in the system. I've meanwhile encountered two more apps with this issue, both working fine on another device which also runs MM. So to clarify: the device I'm having this issue with is an LG P880 running LOS13 (Android 6.0.1) – the "other one" I referred to is a Wileyfox Swift running CyanogenOS 13 (also Android 6.0.1).

@curiousrom
Copy link

curiousrom commented Nov 21, 2017

@yeriomin

So you didn't actually change the default path?

No.

Where are the apks saved?

As shown in the screen capture in my post above, in the default for my Samsung S3 I9300 running LineageOS 14.1 in Yalp Store > Settings > Download directory : /storage/emulated/0/Download.

Absolute path of the other Download folder I created in my external SD card (per ES File Explorer > select the folder > i ) but did not use so far for Yalp: /storage/632B-09F5/Download.

There are some reported issues with the path of external SD cards or mounting them or their usage by some apps in LineageOS for some devices.

For example some S3 I9300 Lineage 14.1 users reported problems with Root Explorer but not with ES File Explorer of Solid Explorer: https://forum.xda-developers.com/search/thread/3544531?query=root%20explorer

I just tried to type that absolute path in > Yalp Store > Settings > Download directory > to try to save the apk's in the external SD card/Download folder I created but it does not work as shown in the screen captures below because it's not possible to overwrite the path /storage/emulated/0/.

Default:

screenshot_20171121-013958

Editing > Yalp Store > Settings > Download directory >

screenshot_20171121-122928

Result:

screenshot_20171121-122950

@curiousrom
Copy link

curiousrom commented Nov 21, 2017

Samsung Galaxy S3 (i9300) with Lineage OS 14.1 (20171117-NIGHTLY-i9300) Rooted. Yalp Store 0.30 excluded from Privacy Guard.

@yeriomin

I'm starting to think the important thing in this workaround is to kill Yalp, and after the OS starts a different process for it, the permission is granted properly...

You are correct I think. To test this I uninstalled Yalp Store & rebooted.

1- Installed com.github.yeriomin.yalpstore_30.apk
2- Before running Yalp went in Lineage's > Settings > Personal > and disabled Privacy Guard for Yalp to make sure it can do what it wants.
3- Yalp > Your apps > selecting an app > Get local apk said "Saved in your Downloads folder" but nothing was downloaded in the default (for my device/OS) /storage/emulated/0/Download folder. No error message!
4- Yalps > Searched for an app (Wi-Fi Transfer), selected it & tapped Download and "Allowed Yalp Store to access photos, media, and files on your device".
5- Got the "Downloads directory could not be created or is not writable." error.
6- Killed Yalp, restarted it and redid steps 3 & 4: success!

@Araucarier

If I look in the privacy protection settings in the settings of android and select Yalp store, I can see, that the change of settings was one time denied, although I definitely clicked on granting access to the storage. I tried it 3 times with a freshly installed yalp store and I always have the same beaviour.

If I go to Lineage's > Settings > Personal > Privacy > disabled Privacy Guard for Yalps long press after killing Yalps & restarting Yalp I can also see Modified settings denied 2 times (last screen capture below) but it did not prevent successful apk download after killing/restarting Yalp. Did you try it instead of re-installing Yalp?

Anyway, thank you @yeriomin for working on Yalps Store!
+++
screenshot_20171121-152516
+++
screenshot_20171121-152558
+++
screenshot_20171121-152620

Lineage's > Settings > Personal > Privacy > disabled Privacy Guard for Yalps:
screenshot_20171121-164615

@rancidfrog
Copy link

For External storage to work, as Android has complicated interactions with external sd,
You can follow FX file explorer approach:
Enable write access or Select Destination/Storage Location,

Ask permission, (needed for any external storage including OTG),

Use Android System dialog to select storage,



This process needs to be done for every new storage location, for example change external sd card.

yeriomin added a commit that referenced this issue Jan 8, 2018
If two ExternalFilesDirs are available, the non-removable is going to be
used now. Also, if setting a download directory in the preferences
screen fails, a fallback directory will be suggested.
@yeriomin
Copy link
Owner

@IzzySoft @Araucarier @pcercuei @sky321 @monteverde-org

I've added a couple of things to help work around the problem...

  • In case two external storage roots are available in the system, the emulated, non-removable one will be chosen. (it used to be just a call to Environment.getExternalStorageDirectory() which apparently would return anything, depending on the vendor and ROM, I guess)
  • If the user tries to change the download directory and the directory is not writable for any reason, an internal fallback directory which should be writable regardless of permissions is suggested. (it is a directory returned by Context.getExternalFilesDir(), which is almost always <external storage>/Android/data/com.github.yeriomin.yalpstore/files)
  • Exceptions are caught and logged instead of being thrown. No point in prodding the user to give bug reports anymore.

If you have time, please check if it actually works as I described on your devices. Please, use v0.34 from the github releases page, f-droid hasn't compiled it yet.

@pcercuei
Copy link

It does show a message asking me if I want to use the fallback directory. By doing so, the downloads work.

@yeriomin
Copy link
Owner

Seems to be working as expected. Time to close this.

@pcercuei
Copy link

Well, the bug isn't fixed, is it? I'm still unable to change the directory, it only works if I use the fallback one.

@yeriomin
Copy link
Owner

@pcercuei The point of the issue was to let people download. Changing the directory is not essential. Yalp Store is not a file manager. Implementing all the possible ways to access all storage devices available is not a priority.

@decentral1se
Copy link

Thanks folks! Helped me get through this one.

@genodeftest
Copy link

I'm still seeing this bug. Thanks to the descriptions above, I found a workaround for me:
In yalp, open Settings from the three-dots-menu, then enable (check) Download to internal storage.

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

No branches or pull requests

9 participants