AAPT: error: attribute android:requestLegacyExternalStorage not found

Evgeny Sermyagin picture Evgeny Sermyagin · Nov 21, 2019 · Viewed 40.4k times · Source

collection error in AndroidManifest.xml

AAPT: error: attribute android:requestLegacyExternalStorage not found.

Although the attribute is there but it writes an error

My AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>

<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="android.apps">

<uses-feature android:name="android.hardware.wifi" android:required="false" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application
    android:allowBackup="true"
    android:fullBackupContent="true"
    android:icon="@mipmap/launcher_icon"
    android:label="@string/app_name"
    android:requestLegacyExternalStorage="true"
    android:roundIcon="@mipmap/launcher_icon"
    android:supportsRtl="true"
    android:theme="@style/Theme.MaterialFiles"
    tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">

    <activity
        android:name="android.apps.filelist.FileListActivity"
        android:label="@string/file_list_title"
        android:theme="@style/Theme.MaterialFiles.TransparentStatusBar"
        android:visibleToInstantApps="true"
        tools:ignore="UnusedAttribute">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter tools:ignore="AppLinkUrlError">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="inode/directory" />
            <data android:mimeType="resource/folder" />
            <data android:mimeType="vnd.android.document/directory" />
        </intent-filter>
        <!-- @see android.apps.file.MimeTypes#isSupportedArchive(String) -->
        <!--
          ~ We don't really support content URI archives.
          ~ TODO: Figure out a good way to allow choosing this activity only in our app, or
          ~ support content URI archives.
        <intent-filter tools:ignore="AppLinkUrlError">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="application/gzip" />
            <data android:mimeType="application/java-archive" />
            <data android:mimeType="application/rar" />
            <data android:mimeType="application/zip" />
            <data android:mimeType="application/vnd.android.package-archive" />
            <data android:mimeType="application/vnd.debian.binary-package" />
            <data android:mimeType="application/x-7z-compressed" />
            <data android:mimeType="application/x-bzip2" />
            <data android:mimeType="application/x-compress" />
            <data android:mimeType="application/x-cpio" />
            <data android:mimeType="application/x-deb" />
            <data android:mimeType="application/x-debian-package" />
            <data android:mimeType="application/x-gtar" />
            <data android:mimeType="application/x-gtar-compressed" />
            <data android:mimeType="application/x-java-archive" />
            <data android:mimeType="application/x-lzma" />
            <data android:mimeType="application/x-tar" />
            <data android:mimeType="application/x-xz" />
        </intent-filter>
        -->
        <!-- @see https://android.googlesource.com/platform/packages/apps/DocumentsUI/+/master/AndroidManifest.xml -->
        <intent-filter>
            <action android:name="android.intent.action.OPEN_DOCUMENT" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.OPENABLE" />
            <data android:mimeType="*/*" />
        </intent-filter>
        <!--
          ~ Unusable until we implement DocumentsProvider.
        <intent-filter>
            <action android:name="android.intent.action.CREATE_DOCUMENT" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.OPENABLE" />
            <data android:mimeType="*/*" />
        </intent-filter>
        -->
        <intent-filter>
            <action android:name="android.intent.action.GET_CONTENT" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.OPENABLE" />
            <data android:mimeType="*/*" />
        </intent-filter>
        <!--
          ~ Unusable until we implement DocumentsProvider.
        <intent-filter>
            <action android:name="android.intent.action.OPEN_DOCUMENT_TREE" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        -->
        <intent-filter>
            <action android:name="android.apps.intent.action.VIEW_DOWNLOADS" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <meta-data
            android:name="android.app.shortcuts"
            android:resource="@xml/shortcuts" />
    </activity>

    <activity
        android:name="android.apps.filelist.OpenFileAsDialogActivity"
        android:autoRemoveFromRecents="true"
        android:icon="@drawable/open_as_icon"
        android:label="@string/file_open_as_title"
        android:theme="@style/Theme.MaterialFiles.Translucent" />

    <activity
        android:name="android.apps.ftpserver.FtpServerActivity"
        android:label="@string/ftp_server_title"
        android:launchMode="singleTop"
        android:theme="@style/Theme.MaterialFiles">
        <intent-filter>
            <action android:name="android.apps.intent.action.MANAGE_FTP_SERVER" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="android.apps.filelist.FileListActivity" />
    </activity>

    <activity
        android:name="apps.settings.SettingsActivity"
        android:label="@string/settings_title"
        android:launchMode="singleTop"
        android:theme="@style/Theme.MaterialFiles">
        <intent-filter>
            <action android:name="android.intent.action.APPLICATION_PREFERENCES" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="android.apps.filelist.FileListActivity" />
    </activity>

    <activity
        android:name="android.apps.settings.StandardDirectoriesActivity"
        android:label="@string/settings_standard_directories_title"
        android:launchMode="singleTop"
        android:theme="@style/Theme.MaterialFiles">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="android.apps.settings.SettingsActivity" />
    </activity>

    <activity
        android:name="android.apps.settings.BookmarkDirectoriesActivity"
        android:label="@string/settings_bookmark_directories_title"
        android:launchMode="singleTop"
        android:theme="@style/Theme.MaterialFiles">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="android.apps.settings.SettingsActivity" />
    </activity>

    <activity
        android:name="android.apps.about.AboutActivity"
        android:label="@string/about_title"
        android:launchMode="singleTop"
        android:theme="@style/Theme.MaterialFiles">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.filemanagere.android.apps.filelist.FileListActivity" />
    </activity>

    <activity
        android:name="android.apps.filejob.FileJobActionDialogActivity"
        android:autoRemoveFromRecents="true"
        android:theme="@style/Theme.MaterialFiles.Translucent" />

    <activity
        android:name="android.apps.filejob.FileJobConflictDialogActivity"
        android:autoRemoveFromRecents="true"
        android:theme="@style/Theme.MaterialFiles.Translucent" />

    <activity
        android:name="android.apps.viewer.text.TextEditorActivity"
        android:label="@string/text_editor_title"
        android:theme="@style/Theme.MaterialFiles">
        <intent-filter tools:ignore="AppLinkUrlError">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="application/ecmascript" />
            <data android:mimeType="application/javascript" />
            <data android:mimeType="application/json" />
            <data android:mimeType="application/typescript" />
            <data android:mimeType="application/x-sh" />
            <data android:mimeType="application/x-shellscript" />
            <data android:mimeType="application/xml" />
            <data android:mimeType="text/*" />
        </intent-filter>
    </activity>

    <activity
        android:name="android.apps.viewer.image.ImageViewerActivity"
        android:label="@string/image_viewer_title"
        android:theme="@style/Theme.MaterialFiles.Immersive">
        <intent-filter tools:ignore="AppLinkUrlError">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="image/*" />
        </intent-filter>
    </activity>

    <service android:name="android.apps.filejob.FileJobService" />

    <service android:name="android.apps.ftpserver.FtpServerService" />

    <provider
        android:name="android.apps.AppProvider"
        android:authorities="@string/app_provider_authority"
        android:exported="false" />

    <provider
        android:name="android.apps.file.FileProvider"
        android:authorities="@string/file_provider_authority"
        android:exported="false"
        android:grantUriPermissions="true" />

    <receiver android:name="android.apps.filejob.FileJobReceiver" />

    <receiver android:name="android.apps.ftpserver.FtpServerReceiver" />

    <meta-data
        android:name="firebase_crashlytics_collection_enabled"
        android:value="false" />

    <!-- We need to reference a MD2 theme in XML for R8 to keep relevant resources. -->
    <activity
        android:name=".KeepMd2Resources"
        android:theme="@style/Theme.MaterialFiles.Md2" />
</application>

Знаете кого-нибудь, кто может ответить? ошибка сбора в AndroidManifest.xml

AAPT: ошибка: атрибут android: requestLegacyExternalStorage не найден.

For ionic developers please refer to this answer to fix this issue: https://stackoverflow.com/a/65595715/10533962

Answer

Hai Zhang picture Hai Zhang · Nov 23, 2019

(Material Files aurthor here)

You need to compile against SDK 29 and maybe use the most recent build tools for aapt to know this attribute, because it's introduced in Android 10.