React Native - Play 商店警告 "Starting May 5th you must let us know why your app requires broad storage access"

React Native - Play Store Warning "Starting May 5th you must let us know why your app requires broad storage access"

我有一个在 Play 商店上架了一段时间的 React 本机应用程序,最近我收到了来自 Play 商店的重要通知,说明如果我不解决这个问题,我的应用程序将从 Play 商店中删除。

谁能告诉我这是什么以及如何解决它?

这是来自 Play 商店的完整消息

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.

我的package.json

{
    "@react-native-async-storage/async-storage": "^1.13.4",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-navigation/bottom-tabs": "^5.11.8",
    "@react-navigation/drawer": "^5.12.3",
    "@react-navigation/material-bottom-tabs": "^5.3.14",
    "@react-navigation/native": "^5.9.2",
    "@react-navigation/stack": "^5.14.2",
    "axios": "^0.21.1",
    "fuse.js": "^6.4.6",
    "react": "16.13.1",
    "react-native": "0.63.4",
    "react-native-device-info": "^8.0.1",
    "react-native-gesture-handler": "^1.10.0",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-paper": "^4.7.1",
    "react-native-reanimated": "^1.13.2",
    "react-native-safe-area-context": "^3.1.9",
    "react-native-screens": "^2.17.1",
    "react-native-svg": "^12.1.0",
    "react-native-vector-icons": "^8.0.0"
}

和manifest.xml

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

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

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:theme="@style/AppTheme"
      android:usesCleartextTraffic="true">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize">
        <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" />
    </application>

</manifest>

同样在 App bundle explorer 下的 Play Console 中,我发现我的应用正在使用以下权限:

据我所知,即使目标为 Android 11:

,我们也应该能够使用此选项解决问题
  • 更新您的应用以在清单文件中声明所有文件访问权限(MANAGE_EXTERNAL_STORAGE),并从 5 月 5 日起在 Play 管理中心完成所有文件访问权限声明

我认为这是解决 android:requestLegacyExternalStorage="true" 将在 Android 11 上被忽略这一事实的方法。虽然我不确定如何声明所有文件访问权限播放控制台。应该有某种形式,您应该在其中指定您的应用程序需要此权限的原因。谁能看到这张表格在哪里?

可能是您正在使用一些调用 MANAGE_EXTERNAL_STORAGE

的 RN 依赖项

例子 路径示例 -> /MyProject/node_modules/rn-fetch-blob/android/src/main/AndroidManifest.xml

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

即使我没有使用它,我也安装了这个依赖 RNFetchBlob rn-fetch-blob,所以你可能需要寻找使用 WRITE_EXTERNAL_STORAGE 或 android:requestLegacyExternalStorage= 的外部依赖“真”

我从位于以下位置的日志中找出导致我的合并 AndroidManifest.xml 包含 android:requestLegacyExternalStorage 的原因:

./android/app/build/outputs/logs/manifest-...-report.txt

只需在文件中找到 requestLegacyExternalStorage

未修复,但 Reddit 上有一个主题,您可能有兴趣阅读。有人收到此消息的报告,即使他们没有启用 requestLegacyExternalStorage 标志。

我发现,如果我们的目标是 Android API 29,我们不必担心警告,只需在您应用的清单文件中设置 requestLegacyExternalStorage=true

尽管我们必须在 11 月之前升级到 Android API 30。