“canvas save as” doesn’t save

Try just setting a filename without a path, remove DCIM/Camera

What android do you use? When saving in the DCIM folder, the property "Scope" should be set to shared.

I want to specify a path.

Galaxy Note 11 / Android 11
Permissions have been set.

First test that it actually works (saving a canvas), then we work on the path :wink:

How to move files in App Inventor?

@Judy thank you for your bug report...
theoretically this should work


and it works like this using the companion app...
however after building it fails (on Samsung Galaxy A51 running Android 11) with the following error message:

The permission WRITE_EXTERNAL_STORAGE has been denied. Please enable it in the settings app.

Note: there is no WRITE permission anymore in Android 11...

This bug is similar to the file component bug reported by @Anke here

Taifun
PS: I changed the category of this thread to #bugs


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

1 Like

Yes exactly, it only works if WRITE permission is declared in the Manifest.

This works for me on Android 10 & 11, companion and compiled...

image

/storage/emulated/0/Android/data/<package_name>/files/mycanvas.jpg

If you need to get on and save the canvas somewhere....

1 Like

Android 11:

@Anke please elaborate a little bit, what exactly you are trying to say with your blocks...
probably the Canvas is able to save something to the shared storage /Download?

Taifun

Yes, but the same problem with WRITE permission, so you must grant storage permission and WRITE permission must be declared in the Manifest. That is very strange, because WRITE cannot be granted on Android 11. But if I deny permisson I get Error ... WRITE_EXTERNAL_STORAGE has been denied. Please enable ...

Btw, I also tried to only declare WRITE in the Manifest, with the same result.
So what permission is the Canvas component asking for?
This is definitively a bug. @ewpatton

I'm still working on it, but I think the issue is that the Canvas component always asks for write permission, which is problematic in Android 11 because the permission is gone. Effectively, the Android system reports the permission as being denied, and so the Save block signals a failure due to the lack of permission when in fact it should proceed as normal. I'm going through and auditing every component that references the WRITE_EXTERNAL_STORAGE permission to see if this is a problem elsewhere as well.

2 Likes

Same for android10.

(added to FAQ)

It can only be READ permission as WRITE works like READ on Android 11.

It wouldn't be easier, faster, better to get rid of all this complicated automatic permission granting, and to make a module in ai2, an additional menu in which users themselves decide what permissions to grant to their app? Make a check box list of all possible permissions, add "min - max sdk api lewel" fields, and based on these settings, add permissions to the manifest. Users would have more control over the permissions of their apps, and MIT would not have to worry about how to fix this automation. Even in the future, when Google comes up with more bizarre stuff, it would work.

There will be a UI at some point to override some of these things, especially because for the iOS build you need to be able to specify actual strings that are compile time to describe why you need the permissions. However, the typical App Inventor clientele has no real use of managing permissions and it would likely get in the way in most cases. Remember that most of our users are middle and high school students and teachers following well-defined curriculum. All of the curricula would need to be updated if in addition to building the app you had to also go about specifying permissions, etc. Folks are welcome to use Android Studio if they want that level of complexity.

Yes, I know it's an educational platform. But I look from you, you would have less work to do with it. After that, granting the proper permissions, as well as other decisions made before compilation, are also some kind of education. The more Ai2 does in the background for the user, the less the user learns. If we think of ai2 as a way to introduce people to the android world and thus prepare people for programming in an "Android Studio", besides logic and graphics, people should also learn other things. I used to think why ai2 took the indexing logic from "1" if android starts with "0". Well, but I understand that 1 is better digestible for an ordinary user.

1 Like

This is not necessarily true. It allows the user to focus on learning other things. Just because they aren't learning things you think are important doesn't mean they aren't learning.

4 Likes