'AAPT: error: attribute android:preserveLegacyExternalStorage not found
I am migrating an app to API level 30 and trying to follow the guidelines from here. It says:
If your app targets Android 11
Set the
preserveLegacyExternalStorageflag to true to preserve the legacy storage model so that your app can migrate a user's data when they upgrade to the new version of your app that targets Android 11.
As advised, I am setting the flag in respective build flavor's manifest file and there are no warnings or errors inside the code editor. However, problems occur when I try to build the app. I am receiving the following error:
AndroidManifest.xml:25: AAPT: error: attribute android:preserveLegacyExternalStorage not found.
AndroidManifest.xml is the following:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:preserveLegacyExternalStorage="true">
</application>
</manifest>
The relevant parts from build.gradle file are the following:
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.example.test"
minSdkVersion 21
targetSdkVersion 30
versionCode 41
versionName "5.3.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
flavorDimensions "payments", "API"
productFlavors {
google {
dimension "payments"
}
cc {
dimension "payments"
}
defaultAPI {
minSdkVersion 30
targetSdkVersion 30
dimension "API"
}
maxAPI29 {
dimension "API"
targetSdkVersion 29
versionNameSuffix "-maxAPI29"
}
}
}
dependencies {
...
}
That is, build tools and compile SDK version are set to 30. What else I might be missing?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
