Flutter ImagePicker error "attribute android:requestLegacyExternalStorage not found"

4,926

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” 
Share:
4,926
ArtS
Author by

ArtS

Updated on December 23, 2022

Comments

  • ArtS
    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 has compileSdkVersion 28 under android, and minSdkVersion 16 and targetSdkVersion 28 under defaultConfig. I'm not familiar with this, but I assume these fits the API<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: enter image description here

    What should I do about this? Thank you!

  • Dani
    Dani about 3 years
    buildToolsVersion doesn't exist inside the whole android folder