-
Notifications
You must be signed in to change notification settings - Fork 34
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
No project directory on Android #83
Comments
Hi @NiklasEi, that should work, can you check whether Thanks, Simon |
Hey @soc, |
I am getting the same response from |
I suspect that Does Android have any sensible definition of a home directory? Looking at the implementation, https://github.com/dirs-dev/dirs-sys-rs/blob/main/src/lib.rs#L33, we rely on the environment variable and do not offer a fallback. Can you check whether the env var is set on Android? |
Running It seems that the intended way of getting the correct directory is calling Context#getFilesDir, which according to the android stackexchange should point to I tried some paths in my app and managed to write and read from |
I might have found something with env variables: https://cs.android.com/android/platform/superproject/+/refs/heads/master:frameworks/base/core/java/android/os/Environment.java;drc=a3bb1640c5a3422645b8493ee0bb00eab4266c32;l=98 There seem to be multiple possible directories for a given application and I cannot see another way to get the intended one from a simple environment variable. See https://cs.android.com/android/platform/superproject/+/refs/heads/master:frameworks/base/core/java/android/app/ContextImpl.java;l=2950 |
I ended up using the actual app context via |
I think it would make sense to generally use Android-level APIs in the implementation instead of trying to pretend that Android is just another Linux as |
iirc some android phones offer multi-user functionality and this is why they have this structure |
@NiklasEi here you can see how the tauri project looks up directories on Android https://github.com/tauri-apps/tauri/blob/48b1fd74b1df5c3628d00aaae9371dd094466fe5/core/tauri/src/path/android.rs |
I would recommend against implementing this in Another point against this is that the actual location that an app can write to on Android is an implementation detail. I'm pretty sure it's not guaranteed anywhere, so it can be altered by the device vendor. Android fragmentation is a massive problem and it's not a maintenance burden that directories should take on, IMHO. Trying to bypass the Android APIs to get this implemented in directories is just asking for trouble. Google breaks things like this on each new version of Android, and it's painful enough if you are using the offical APIs! |
I am also against adding complexity via FFIs. It's probably better to have something that works on a number of devices than none. What do you think about trying to detect write access heuristically?
Wouldn't /data/data simply be a physical link or a symbolic link to /data/user/0/.... which makes it possible to simplify usage when a person connects in an authorized manner on a android? I haven't checked. We could start from the existence of ANDROID_DATA:
2.1 if "user" loop over the <identifier> in descending order This location could then serve as the root for the lib? What do you think ? Do you see any contraindication? |
My guess is we can always write here :
My guess is we can always write here : I ask chat-gpt and mixtral 8x7B-32768 about that and AI confirm. Heuristic detection is certainly usefulness. Real question is now where to map
|
I have done a small piece of code to review: here |
I am calling the following on Android
and get back
None
. The package identifier isme.nikl.game
and the app is running on a real device with Android 12.Is there anything I need to setup or configure to get a proper project directory on Android?
The text was updated successfully, but these errors were encountered: