Flutter ImagePicker error "attribute android:requestLegacyExternalStorage not found"
To solve that issue, in "build.gradle (Project)", set the "compileSdkVersion", "buildToolsVersion" and "targetSdkVersion" as 29 like this:
buildToolsVersion = “29.0.0”
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
supportLibVersion = “28.0.0”
ArtS
Updated on December 23, 2022Comments
-
ArtS over 1 year
I use image_picker in my flutter project. It says "API < 29 ----> Add android:requestLegacyExternalStorage="true" as an attribute to the tag in AndroidManifest.xml. The attribute is false by default on apps targeting Android Q."
In
build.gradle
, it hascompileSdkVersion 28
underandroid
, andminSdkVersion 16
andtargetSdkVersion 28
underdefaultConfig
. I'm not familiar with this, but I assume these fits theAPI<29
condition. So I added the attribute.Then my project won't compile anymore with error saying "AAPT: error: attribute android:requestLegacyExternalStorage not found." It compiles if I delete
android:requestLegacyExternalStorage="true"
. However since it specifically asks to add this attribute, I want to figure this out to avoid any potential problems like rejection on iOS for permission related issues.After adding the attribute, my
AndroidManifest.xml
looks like:What should I do about this? Thank you!
-
Dani about 3 yearsbuildToolsVersion doesn't exist inside the whole android folder