Sketchware-Pro / Sketchware-Pro

Sketchware Pro's sources in Java. Now anyone can contribute to Sketchware Pro.
https://sketchware.pro
Other
853 stars 252 forks source link

Sketchware's compiler doesn't support multi-user devices #1106

Closed HehehBoiii78 closed 1 month ago

HehehBoiii78 commented 1 month ago

How it occurred I imported or restored a project in Sketchware that used local libraries for the first time. It asked me if I wanted to import the libraries or not and I said yes to the dialog. Then I tried to compile the app once but it failed with a dialog that said "A directory important for building is missing. Sketchware Pro can try creating the directory at storage/emulated/0/.sketchware/libs/local_libs/my_project/res if you'd like to." The issue The issue is that it is trying to access and write a folder to /storage/emulated/0 which is not my user's directory. I am using this app in a Samsung tablet which supports multi-user, and my directory is not /storage/emulated/0 but instead /storage/emulated/10. Android doesn't allow the user or an app to access another user's directory, and that's why when I try to say yes to the dialog asking to try to create the folder because it doesn't exist, I always get an error. And that's why I cannot compile the app no matter what, even after deleting that local library from the app that it was using. How to reproduce In a device that supports multiple users, switch to another user, install or open Sketchware Pro, import or open an app which uses a local library, and try to compile the app. You will not be able to, because it can't search for or create the folder in the directory which "is important for building". The picture of the error dialog Screenshot of the error dialog in Sketchware Pro

hasrat-ali commented 1 month ago

There's limitation on swpro, but it should be fixed. Any you can just click on `Create' button, that will fixed your problem.

HehehBoiii78 commented 1 month ago

That's the issue. The create button itself does not work. When I try to click it shows Failed to create folder. Try again later.

HehehBoiii78 commented 1 month ago

And also, please clarify the reason of closing this issue.

JavkhlanK commented 1 month ago

how's it "not our bug"? i'm 100 % sure some code by agus hardcoded /storage/emulated/0 for dumb reasons, and that's why this isn't working

hasrat-ali commented 1 month ago
  1. ?
  2. There's not any hardcoded /storage/emulated/0.
  3. How it's working for me?
JavkhlanK commented 1 month ago

yeah nvm this is plainly wrong, I just got it to work too. So to conclude, just like Hasrat said, create the directory using the dialog button. Sketchware Pro supports multi-user setups correctly.

HehehBoiii78 commented 1 month ago

How does someone close this issue? Also, @JavkhlanK, that's not plainly wrong. I am using a Samsung tablet using OneUI Core, and it doesn't work for me. I try to import the project, it shows me the dialog that is visible in the picture. Screenshot_20240320-230533_Sketchware Pro No matter if I click on "Don't copy" or "Copy" and try to compile the project, it always says the "Missing directory detected" (the dialog's picture is given in the post) and even if I click on the Create button in the "Missing directory detected" dialog, it ALWAYS gives the error "Failed to create directory/directories"! It is very hard for me to screenshot the error message that says it can't create the folder, because it is a Toast message and not a dialog, but I will still try that.

hasrat-ali commented 1 month ago

you can record a video.

HehehBoiii78 commented 1 month ago

Thanks for the idea. Give me some time.

JavkhlanK commented 1 month ago

I meant "plainly wrong" as in it having worked for both me and Hasrat. I used a Google APIs emulator image, Hasrat probably not a Samsung device. Looks like Samsung messed up in their implementation.

Anyway when you're already recording your screen, please make sure to show the entire process failing, so e.g. the Local library dialog, as well as the entire compile error message.

hasrat-ali commented 1 month ago

Bro, if you still getting those errors, then just simply goto Local Library manager and unselect that library, reselect again.

HehehBoiii78 commented 1 month ago

Will try that, anyway, here is the video of the problem.

https://github.com/Sketchware-Pro/Sketchware-Pro/assets/163304670/5c3dfbfd-e3d1-4cbe-b3dc-567e887c6a90

HehehBoiii78 commented 1 month ago

I apologise for being late, my network wasn't working 💢

HehehBoiii78 commented 1 month ago

Bro, if you still getting those errors, then just simply goto Local Library manager and unselect that library, reselect again.

Thanks for this solution. That fixed my problem. Also, can you answer why does that issue occur in the first place? Why do we have to reselect it anyway?

JavkhlanK commented 1 month ago

Can you show what's inside the Local library's folder? (at /Internal storage/.sketchware/libs/local_libs/ btw)

HehehBoiii78 commented 1 month ago

Alright. Here's what you asked. Screenshot_20240321-001433_My Files Screenshot_20240321-001440_My Files Screenshot_20240321-001450_My Files Screenshot_20240321-001458_My Files

JavkhlanK commented 1 month ago

Thanks. What a weird issue.

PranavPurwar commented 1 month ago

the stuff we save in .sketchware/data/<project_id>/local_library uses absolute path, rather than relative paths. so if a person on multiuser device extracts that project, it will always look for libraries in user space 1 which is restricted