AAPT:错误:找不到属性android:requestLegacyExternalStorage

时间:2019-11-21 13:42:03

标签: android

AndroidManifest.xml中的

收集错误

AAPT:错误:找不到属性android:requestLegacyExternalStorage。

尽管该属性存在,但会写入错误

我的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ненайден。

9 个答案:

答案 0 :(得分:12)

在android \ app \ build.gradle中进行这些更改:

compileSdkVersion 29

targetSdkVersion 29

它将起作用。

答案 1 :(得分:8)

只需删除行android:requestLegacyExternalStorage="true"。您可以在Api 29下使用。

答案 2 :(得分:7)

对于ionic开发者,请确保将cordova更新到最新版本:npm i cordova,然后添加android平台:ionic cordova platform add android@9.0.0

还要确保将这些添加到 config.mxl 中:

<preference name="android-minSdkVersion" value="22" />
<preference name="android-compileSdkVersion" value="29" />
<preference name="android-targetSdkVersion" value="29" />

注意:

SDK v22 意味着低于 5.1 的 android 版本将无法安装该应用程序,知道公司通常将最低 SDK 版本指定为 19 以支持所有设备。

我们不能在 v22 之前的 SDK 上requestLegacyExternalStorage

为了解决这个问题,我们必须在运行 android 10+ 的设备上在运行时添加这个权限。

使用此插件获取当前设备的 SDK 版本: https://ionicframework.com/docs/native/device

如果SDK版本为10或以上,使用本插件请求权限: https://ionicframework.com/docs/native/android-permissions

答案 3 :(得分:6)

如果使用离子型,则将其添加到build.gradle

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 29
                buildToolsVersion "29.0.2"
            }
        }
    }
}

答案 4 :(得分:2)

(此处为材料档案)

您需要使用aapt的最新构建工具来了解此属性,因为该属性是在Android 10中引入的。

答案 5 :(得分:2)

如果您尝试删除android:requestLegacyExternalStorage="true"或更改android:minSdkVersion="xx"android:targetSdkVersion="xx"的值,但是恢复构建后 AndroidManifest.xml ...您应该尝试使用参数进行编译。就我而言(角度8),

tns build android --compileSdk <AndroidVersion> --force

答案 6 :(得分:1)

听起来可能很愚蠢,但是您需要对所有拥有的项目(例如,编译的依赖项)应用compileSdkVersion和targetSdkVersion:

android {
    compileSdkVersion 29
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 29
        ...
}

答案 7 :(得分:0)

对我来说修复是:

onChanged

答案 8 :(得分:-1)

对于构建Nativescript 7项目,我的解决方案是:

  1. 在Android Studio的Android SDK Manager中安装28, 29 & 30 API
  2. 像这样修改app.gradle中的<project>/App_Resources/Android文件: app.gradle file
  3. 运行命令:ns clean
  4. 运行命令:ns debug android