Testing the next release of MIT App Inventor (nb187)

Probably you are testing in Android 11 where that permission doesn't exist.

2 Likes

I really dislike Android 11 :crazy_face:

If i don't use the camera permission but just
image

The camera permission is asked but when i give permission i get the Error 908 message that WRITE_EXTERNAL_STORAGE is denied.

This happens also with the image picker.

2 Likes

If → DefaultFileScope is not set to → Legacy in the Designer

this also happens on Android versions between 4.4 and 9
(Android ≥ 4.4 [KitKat, API 19] and ≤ 9 [Pie, API 28]),
because the maxSdkVersion for READ / WRITE is 18.

<uses-permission android:maxSdkVersion="18" android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:maxSdkVersion="18" android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

See also here:

EDIT: If you set → DefaultFileScope to → Legacy in the Designer:

grafik

READ / WRITE permission are declared this way:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

and it seems to work (also on Android 11).

2 Likes

But I think to ask for READ permission should also be possible on all DefaultFileScope and all Android versions, because READ permission behaves the same way on all Android versions.

grafik

Yes legacy is working in an apk for now? Wondering if turning it into an aab would make difference.

You have to upload the AAB to the Play Store (e.g. as an internal test track) and then download the general APK or use the Bundletool. But the AAB should work just like the APK.

I will try. Still don't understand what happened to the font size of imagepicker and button.

I've come up with a fix for the regression in the button text:

1 Like

Hmm. I'll have to think about that. The logic in my head when I implemented this is that Legacy encompasses the older behavior, whereas any of the new scope types apply the scoped storage restrictions of Android 10+. In most cases, I think this is fine because App specific storage, private, etc. won't require read/write permissions (after Kit Kat Android no longer required READ/WRITE for app-specific storage, and before that you didn't need to ask for permission anyway--that was introduced in Android 6.0).

In any case, the Legacy default scope should drop the maxSdk of 18.

1 Like

Nevertheless, it should always be possible to request READ permission on all Android versions and not only on devices with Android below KitKat (to get permissions for the ASD on those devices - below KitKat, API 19).

Because READ permission behaves the same on all Android versions.

What does that mean exactly?

I realize I'm a novice, but I'm thoroughly confused about the scoped storage changes, even after reading up about it. Are documents like .csv and .txt going to be able to be shared between app inventor apps after targeting sdk 30?

There is a bug in the ctrl+c and ctrl+v in a table arrangement. The problem is that if you do a ctrl+v in the designer table arrangement, the cell can not be selected and therefore disorganized the designer layout.

Last sentence ...

2 Likes

The copy and paste bug with the TableArrangement is a known issue in the older version as well. There was some work on a fix, but I don't know that it will make it into this version. Since we can do website updates as smaller release we may punt on getting it merged for this release. The AAB and SDK 30 support are a higher priority for us right now.

2 Likes

I believe that any corrections should be smaller and more often implemented. This would allow for better testing of patches by users while building projects. Not everyone wants to test on test servers, and not everything can be noticed when testing small projects. It would also prevent waiting a year for minor corrections ;). Especially since some of the fixes have been ready for a long time.

4 Likes

The guidance from Google (and Apple as well, for that matter), is that you shouldn't request more permissions than you need, and only request them as soon as you need them, and ideally your app should shut off behavior or fail gracefully when permission is denied.

In the case of the Cache and Private scopes, no permission is needed since they are in the private data directory, which is always readable/writeable by the app. In the case of the App scope, READ permission is not needed starting with SDK 19, but still need on SDK 18 and earlier (which is why you get the maxSdk assertion in the manifest).

Legacy scope attempts to provide the existing semantics for App Inventor where possible and therefore cannot assert a maxSdk (I guess it could for SDK 29+) since the app might read/write anywhere. So if you want to read/write arbitrary locations one MUST set DefaultFileScope to Legacy. In the manifest, you'll get the READ/WRITE permissions, and the manifest will not include the SDK constraint (again, subject to change w.r.t. SDK 29+).

By default, apps will use the App scope to be in compliance with the restrictions in newer versions of Android going forward. Existing apps that need the old behavior will need to switch to Legacy. I would encourage everyone to try and build new apps to comply with the more recent restrictions in Android as I expect Google won't ever role back these changes.

I was trying to copy a text file from the assets to the shared directory /Downloads
wooHoo
blocks
I set DefaultScope to Shared in the Designer (does it have any influence here?)
shared
the companion app crashed (I used the latest version 2.60t6u), here is the logcat output
companion
same happens in the apk file...

so the question is: how to correctly copy a file to a shared directory?

Taifun
copyToShared.aia (2.1 KB)

2 Likes

Thanks @Taifun. I'm trying to track down the source of this error. We'll need to update the test server with another fix.

2 Likes

Yes that's right. But why shouldn't it still be possible to access (read / list) files* from the external storage (outside the ASD)?
→ (* btw, on Android 10+ you can only access media files)

However, this is only possible if DefaultFileScope = Legacy.

Same answer / question as before.

What does this exactly mean?
(Of course READ can be requested on any Android version.)

Apparently, it is implicitly assumed that if DefaultFileScope is NOT set to Legacy, only files in the ASD (or, if applicable, the shared storage) should be accessed. So again: Why shouldn't it also be possible to access the external storage on devices with Android 4.4 and up? (e.g. with DefaultFileScope = App) The big disadvantage would then be that from Android 4.4 (API 19) onwards, READ / WRITE permissions can no longer be requested. However, this should be possible.

It is not clear to me where the advantage / sense should be to set maxSdkVersion = 18. Because READ permission can be requested on all Android versions (independent of and therefore also with targetSdkVersion = 30). Of course WRITE permission does no longer exist on Android 29+ and is therefore ignored on Android 29+ devices.

The only disadvantage (not setting maxSdk=18) would be that on devices between Android 4.4 (API 19) and Android 5.x (API 22) READ / WRITE is requested at install-time (which hardly anyone will notice and which was also the case before).

In my opinion, the permissions for all DefaultFileScopes should be declared like this (btw, also with Companion):

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />

Conclusion:
This could also omit the DefaultFileScope property in the designer, which would reduce confusion - especially for inexperienced users.

1 Like

No, see the design document .

DefaultScope (Designer Only)

Specifies the default scope for file operations by different components. For the File component, the File's DefaultScope property overrides this property. For all other components, their paths are resolved based on the value of this property. The default value of this property will be App.

You still want to be able to decide, if for example the camera component stores its taken images in the ASD or a shared directory...

Taifun