For reprint, please indicate the original source: https://juejin.cn/post/6850418117093523464, thank you.

The problem

Recently met a lot of people ask the project operation error AAPT: error: attribute android: requestLegacyExternalStorage not found. The problem.

why

Build. gradle-compilesdkVersion < 29 And also in the AndroidManifest. XML – application configuration in the android: requestLegacyExternalStorage properties (whether I project, or a third-party library configured with this property), and will lead to the problem. The main effect of this property is due to the storage permission adjustment in Android 10.0, a temporary solution released by Google. Google official document: external storage access management partition, |, Android Developers, |, Android Developers

To solve

1. Removeandroid:requestLegacyExternalStorageattribute

If it is configured by your own project

Directly in the AndroidManifest. XML – removes the android application: requestLegacyExternalStorage properties.

If configured by a tripartite library

In additional qualifications purpose AndroidManifest. XML – application add tools: remove = “android: requestLegacyExternalStorage”. The principle is to remove this attribute directly when the manifest file is merged. Google official document: merge multiple listing file, |, Android Developers, |, Android Developers

2. ChangecompileSdkVersionversion

Change build. gradle-compilesdkVersion to version greater than or equal to 29.