I upgraded my app to API 30 recently. I used Mediastore to handle all of my image and video files (Scoped storage), no longer depend on WRITE_EXTERNAL_STORAGE permission. But I forgot to restrict the permission to 28.
So instead of this,
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28">
It looks like this
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE">
We aren't releasing a new version of the app until Nov 1,2021 which is Google's deadline for all the apps to be in API 30. My question is, Will there be an issue on Nov 1 as I didn't add android:maxSdkVersion in my Manifest file or will it be ignored?
Related
I need to migrate my application from android 12 to android 13 since in android 12 it does not show any errors, however when testing the app on a device with android 13 it gives me the following error:
[MethodChannelFilePicker] Platform exception:
PlatformException(read_external_storage_denied, User did not allow
reading external storage, null, null).
I've tried adding validations in the manifest, like the ones in:
I have also tried adding these validations in the main:
Add the following permission in your manifest.xml inside
<uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
If it still does not work out, upgrade or change the package you use for picking files and check the documentation.
recommended : https://pub.dev/packages/file_picker/versions/5.2.5
In API 33 (Android 13), granular media permissions have been introduced, and developers have to request these granular permissions instead of READ_EXTERNAL_STORAGE.
READ_MEDIA_AUDIO is one such granular permission. This permission exists only in API level 33+, so my question is, which permission should I request in the manifest?
Since my app has minSDK = 21, should I request both READ_EXTERNAL_STORAGE and READ_MEDIA_AUDIO in the manifest. Or should I only request READ_EXTERNAL_STORAGE and that will cover READ_MEDIA_AUDIO? (At runtime, of course, I will ask for either of the permission based on the SDK_INT of the device.)
You should add both permissions to your manifest
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
The READ_MEDIA_AUDIO permission will work only for devices with Android 13 or above.
Then, as you wrote, you should handle each case of the SDK (this section may be helpful for other developers):
for the SDK 21 and 22 the permission will be added automatically after the app installation
starting from the SDK 23 you should use the runtime permissions for the READ_EXTERNAL_STORAGE permission (https://developer.android.com/training/permissions/requesting)
there were changes related to the external storage starting from Android 11 (SDK 30), however, you still can download audio files using the same READ_EXTERNAL_STORAGE permission. Regarding the changes, for example the directory Recordings exists only from the SDK 31 (source: https://developer.android.com/training/data-storage/shared/media#media_store)
starting from the SDK 33 request the granulated permission READ_MEDIA_AUDIO
WRITE_EXTERNAL_STORAGE pemission pop up not display after upgrading to tragetsk 33 and compile sdk 33 in kotlin.
With same code, permission Pop up is showing in android 10 ph.
But not showing in android 13 ph. the checking grant result for WRITE_EXTERNAL _STORAGE permission is -1 which is not granted.
For android versions which less than API 29 (android 10)
you need to request WRITE_EXTERNAL_STORAGE .
otherwise it's already granted because of ScopedStorage that released at android 11.
you can still use WRITE_EXTERNAL _STORAGE in android 10 if you add requestLegacyStorage = true to your manifest, but thats will not work for greater versions .
you should read about ScopedStorage: https://developer.android.com/about/versions/11/privacy/storage
and update your manifest to:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
I have a working code that exports some files in the Downloads folder. I'm using requestLegacyExternalStorage to be able to access the folder on Android 10-. Everything works.
Since Google Play Store requested to remove the flag
requestLegacyExternalStorage="true"
I have tried to remove it. I don't need to migrate anything so it has been relatively simple and it works fine on Android 9- and Android 11. On Android 10 it does not work. The app crashes with
android.system.ErrnoException: open failed: EACCES (Permission denied)
In the AndroidManifest I have:
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="29"/>
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29" />
I have granted permission to access the external store.
The crash happens when I call:
destination.outputStream()
where destination is a file in the Downloads folder.
What should I do? Why doesn't this work on Android 10 only?
The issue on Android 10, because you set in In the AndroidManifest : android:maxSdkVersion="29".
Android 10 is API level 29.
add in AndroidMainfest
in application node
android:requestLegacyExternalStorage="true"
I made a very, very small demo app reproducing the bug on a Nexus 5 running Android version 6.0.1. The app is on github here: https://github.com/lexi-sr/LayerPermission
I recently added 2 commits in which it targets API 23 and requests permissions at run time, but it still didn't work.
In these 2 commits, it has these settings:
Target SDK: 23
compiles Layer 0.20.3
1) In the commit "Removing layer dependency allows the popup dialog to request the perm…", where it does NOT have layer dependency:
The method ActivityCompat.requestPermissions opens a dialog that requests the Contacts permission, and a log statement within the onRequestPermissionsResult method logs that the permission has been granted.
2) In the commit "Requesting permissions does not work" where it DOES have layer dependency:
ActivityCompat.requestPermissions does not open up any dialogs, but a log statement within onRequestPermissionsResult still prints, logging that it does not have the permission.
It seems like adding the layer dependency is suppressing the ability to request for permissions at run time. Why is this happening?
Luckily, the layer support team was able to help me with this. It solved my problem in the demo app (which targeted SDK 23) and my real app (which targeted SDK 22, to avoid requesting permissions at runtime). After I put tools:node="replace" into my uses-permission line for GET_ACCOUNTS, the pop up dialog was able to appear and grant the permission in the demo app, and the permission was no longer missing in the real app which targeted SDK 22.
Here is the detailed explanation from the Layer support team:
The layer SDK requests the GET_ACCOUNTS permission using a
maxSdkVersion of 18. It would appear that when the manifests get
merged this is overwriting the permission request in your manifest,
thus not requesting that permission for 19+. Could you try appending
tools:node="replace" to the permission in your app's manifest? The
line should read as:
<uses-permission android:name="android.permission.GET_ACCOUNTS" tools:node="replace" />
See here for the maxSdkVersion documentation:
http://developer.android.com/guide/topics/manifest/uses-permission-element.html
See here for the tools:node documentation:
http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger#TOC-tools:node-markers
Peter