反应原生应用清单文件中的 requestLegacyExternalStorage 标志

问题描述

We've detected that your app contains the requestLegacyExternalStorage flag in the manifest file of 1 or more of your app bundles or APKs.

Developers with apps on devices running Android 11+ must use Scoped Storage to give users better access control over their device storage. To release your app on Android 11 or newer after May 5th,you must either:

Update your app to use more privacy friendly best practices,such as the Storage Access Framework or Media Store API
Update your app to declare the All files access (MANAGE_EXTERNAL_STORAGE) permission in the manifest file,and complete the All files access permission declaration in Play Console from May 5th
Remove the All files access permission from your app entirely
For apps targeting Android 11,the requestLegacyExternalStorage flag will be ignored. You must use the All files access permission to retain broad access.

Apps requesting access to the All files access permission without a permitted use will be removed from Google Play,and you won't be able to publish updates.

我收到了来自谷歌的上述消息。我已将 reactnative 应用程序清单文件更新为目标 api 30,并删除了 requestLegacyExternalStorage 标志并更新了清单文件和依赖项,如下所示。

我的清单文件如下所示:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.xxx"

  xmlns:tools="http://schemas.android.com/tools"
  >
    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="true"
      android:theme="@style/AppTheme"
      tools:targetApi="30"
      android:usesCleartextTraffic="true" 
      >

      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="adjustPan"
        android:screenorientation="portrait"
        >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
      <Meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_notification" />
   
    </application> 

</manifest>

我的依赖:

 "dependencies": {
    "@flyerhq/react-native-android-uri-path": "1.0.2","@react-native-community/art": "1.2.0","@react-native-community/async-storage": "1.7.1","@react-native-community/datetimepicker": "2.3.0","@react-native-community/masked-view": "0.1.7","@react-native-community/netinfo": "5.3.3","@react-native-firebase/app": "7.0.1","@react-native-firebase/messaging": "7.0.1","@react-navigation/native": "5.0.0","@react-navigation/stack": "5.0.0","@redux-offline/redux-offline": "2.5.2-native.3","formik": "2.1.4","jwt-decode": "3.1.2","lodash.mapvalues": "4.6.0","moment": "2.24.0","native-base": "2.13.8","react": "16.9.0","react-native": "0.61.5","react-native-check-version": "1.0.9","react-native-device-info": "5.5.8","react-native-document-picker": "3.5.4","react-native-gesture-handler": "1.5.6","react-native-iphone-x-helper": "1.2.1","react-native-image-picker": "3.5.0","react-native-loading-spinner-overlay": "1.1.0","react-native-modal": "11.5.4","react-native-modal-datetime-picker": "8.5.1","react-native-progress": "4.1.2","react-native-reanimated": "1.7.0","react-native-safe-area-context": "0.7.3","react-native-screens": "2.3.0","react-native-select-two": "1.1.0","react-native-simple-radio-button": "2.7.4","react-native-splash-screen": "3.2.0","redux-devtools-extension": "2.13.8","redux-persist": "6.0.0","redux-persist-filesystem-storage": "3.0.0","rn-fetch-blob": "0.12.0","yup": "0.28.3"
  }

rn-fetch-blob 库在其清单中有以下几行:

<!-- required to read and write the expansion files on shared storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

这足以更新到 android 11 还是我需要替换这个 rn fetch blob 库?

在社区中正在进行许多讨论。有人说如果我们使用 WRITE_EXTERNAL_STORAGE 它会自动从商店中删除其他人说可以使用此权限,我们可以在 Play Console 中进行声明等等。那么我该如何解决这种情况?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)