"Error 908 : WRITE_EXTERNAL_STORAGE permission is denied" error with screenshot component

Hi all, I’m trying to use the Screenshot component from Utilities, but it isn’t working and saying WRITE_EXTERNAL_STORAGE permission isn’t granted and I need to enable it within settings when trying to run the “Screenshot1.takescreenshot” method. I have an Android 12 Samsung Galaxy A50 (2019) and am testing on a downloaded APK.

I’ve tried the custom manifest extension for read and write permissions by @bodymindpower (not working for some reason), setting the permissions for READ & WRITE beforehand (but WRITE is still giving the same error) and am unable to see WRITE permission specifically in settings.

I’ve read a ton of posts around this issue, almost everyone says this is a known issue since long - I just wanted to ask if there’s a workaround for this yet and how do I make the screenshot component work… Can anyone share any advice on this? Thanks.

as a start what about sharing a screenshot of your relevant blocks?

Taifun

1 Like

Hi @Taifun ! Thanks for replying. My app only has two screens, screen1 & “badge”. screen1 just has a button whose job is to navigate to the other screen, and “badge” only has these blocks -

Error occurs when I click button1; ActivityStarter just has a basic activity which opens the printershare printing app with the screenshot path.

No longer works on

Search in the community as there are bunch of topics by @bodymindpower about this.

2 Likes

It looks like you forgot to set the fikename to store the screenshot in shared storage
Try to set it to

/Download/myScreenshot.jpg

before taking the screenshot

Taifun

1 Like

Hi @Taifun @Boban , thanks for replying.

The component had set “Screenshot.png” as the filename property in designer by default. Now i’ve removed it from designer and am setting it to “/Download/myScreenshot.jpg” right before TakeScreenshot method. Here are my complete updated blocks.

Everything seems to work in Live Companion; I freshly installed the companion and checked, it just one-time asks for “access photos and media” permission on the “badges” screen (pic below) as the TakeScreenshot method is about to run, nothing else; and then takes the screenshot and runs later code as expected.

But when I install as apk on other one of my device which is an android 11 one, same as companion it asks for the above permission on the “badge” screen, but then says WRITE_EXTERNAL_STORAGE permission denied. Is it possible to fix this? If not does this mean we can’t use the screenshot component on apps on Android 11+ phones? Also just curious, why is this working on companion but not on installed app? The companion would need the external storage permission too right? Please advice… Thanks!

This is another bug in Kodular, because the Screenshot component incorrectly requests WRITE permission for the ASD as well (on Android 11+).

However, in Kodular there is no other way than manually declaring WRITE permission in the Manifest also for Android 11+. In AI2 this is possible by setting DefaultFileScope = Legacy, which also makes no sense because WRITE permission no longer exists on Android 11+. (All pointed out dozens of times, including AI2).


PS: I very rarely post anything on Kodular anymore. However, since there is supposed to be a collaboration (a merger) between Kodular and AI2, I’ll point out bugs as a precaution, as I’ve been doing for years on the side.

1 Like

in the blocks you are setting it to myScreenshot.jpg rather than /Download/myScreenshot.jpg

but what happens, if you import an extension, which declares that permission? Probably worth a test… you could try importing the file extension… App Inventor Extensions: File | Pura Vida Apps
let us know, what you find out…

Taifun

This won’t work unless this folder is previously created in the ASD (on Android 11+).

As said before, there is no way to declare WRITE permission for Android 11+ via extension in Kodular. You must declare it manually in the Manifest.

@Taifun @bodymindpower Thanks for replying.

I assume there’s no way to edit the app’s manifest file right, so broadly speaking the screenshot component won’t work on Android 11 & later?

Of course its possible. Adjusting WRITE permission in the Manifest is done in a few seconds.

Of course it works also on Android 11+, but you have to accept that WRITE permission is incorrectly (unnecessarily) requested.

1 Like

Thanks @bodymindpower, I read your How to customize the Manifest → example: Companion APK post, downloaded APK Editor Studio (turns out I didn’t have java so installed it too), and added WRITE permission in my manifest.

Now the downloaded apk works smoothly too :+1: Thanks again!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.