简体   繁体   中英

Flutter ImagePicker error "attribute android:requestLegacyExternalStorage not found"

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: 在此处输入图像描述

What should I do about this? Thank you!

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” 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM