android.permission.WRITE_EXTERNAL_STORAGE should be allowed on SDK 29?

Hi,

This commit caps the android.permission.WRITE_EXTERNAL_STORAGE at sdk 28, but the android docs seem to say they should be capped at sdk 29 (ie, < R, which is 30)? That said, I am having issues with this permission with sdk 30: I can only create a wav file if I go and manually change that line in my manifest

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

to this one

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

otherwise I hit this assert:

Having android:maxSdkVersion="30" works like a charm, I can create and share my file no problem.

I’m seeing in the docs that media files are maybe a different case, so I’ll continue investigating this, but it seems to me at the very least the android:maxSdkVersion should be set to 29?

This is on a OnePlus 6T, android 11

1 Like

According to this page:

If your app is used on a device that runs Android 9 or lower, or if your app has temporarily opted out of scoped storage, you must request the READ_EXTERNAL_STORAGE permission to access any media file. If you want to modify media files, you must request the WRITE_EXTERNAL_STORAGE permission, as well.

In order to opt out of scoped storage, you need to add android:requestLegacyExternalStorage="true" to your manifest, but JUCE doesn’t do this by default, and this will only work on Android 10. So, for JUCE apps that are using scoped storage, I think a maxSdkVersion of 28 is correct.

In order to prepare for scoped storage, you should ensure that you’re using the AndroidDocument class to write files into shared locations.

1 Like

thanks! I ended up resolving my issue (ie, hitting the assert in RuntimePermissions::request()) simply by not requesting the WRITE_EXTERNAL_STORAGE permission. Turns out that creating the file works just fine without it :slight_smile: