如何解决在 react-native 开发模式下需要授予的覆盖权限?

How to resolve overlay permissions need granted in react-native dev mode?

我已将我的 Android 设备从 Android 7.0 更改为 Android 8.0,再更改为 运行 一个 react-native 应用程序。之前在 AndroidManifest 中添加覆盖权限允许应用 运行 并在设备上显示开发者菜单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.simpleoffsetpro"
    xmlns:tools="http://schemas.android.com/tools">
    <uses-permission tools:node="remove" android:name="android.permission.SYSTEM_ALERT_WINDOW" />
</manifest>

但是当我 运行 Android 8.0 上的应用程序时,我授予 "Permit drawing over other apps" 提示的权限。然后应用程序只显示一个带有通知的灰色屏幕 - Overlay permissions needs to be granted in order for react native apps run in dev mode.

设备:华为 P Smart - Android8.0.0

问题:

如何解决在 react-native 开发模式下需要授予覆盖权限?

Package.json 依赖项:

"dependencies": {
    "bluebird": "^3.3.5",
    "convert-units": "^2.3.4",
    "event-emitter": "^0.3.4",
    "immutability-helper": "^2.8.1",
    "immutable": "^3.7.6",
    "lodash": "^4.11.0",
    "moment": "^2.12.0",
    "native-base": "2.0.12",
    "react": "~15.4.2",
    "react-dom": "~15.4.2",
    "react-native": "0.42.0",
    "react-native-awesome-alerts": "^1.0.6",
    "react-native-dismiss-keyboard": "^1.0.0",
    "react-native-floating-label-text-input": "^0.1.4",
    "react-native-hide-with-keyboard": "^1.0.0",
    "react-native-keyboard-listener": "^1.1.0",
    "react-native-localization": "^1.0.11",
    "react-native-material-initials": "^0.0.12",
    "react-native-overlay": "^0.5.0",
    "react-native-popup-menu": "^0.12.3",
    "react-native-swiper": "^1.5.13",
    "react-native-vector-icons": "^4.0.0",
    "react-redux": "^4.4.5",
    "redux": "^3.4.0",
    "redux-logger": "^2.6.1",
    "redux-loop-symbol-ponyfill": "^2.2.0",
    "redux-promise": "^0.5.3",
    "redux-thunk": "^2.0.1",
    "standard-http-error": "^2.0.0"
  },
  "devDependencies": {
    "babel-core": "^6.9.0",
    "babel-eslint": "^7.1.0",
    "babel-jest": "^17.0.2",
    "babel-polyfill": "^6.9.0",
    "babel-preset-react-native": "^1.9.0",
    "babel-preset-stage-0": "^6.5.0",
    "babel-register": "^6.9.0",
    "enzyme": "^2.2.0",
    "eslint": "^3.10.1",
    "eslint-plugin-babel": "^3.2.0",
    "eslint-plugin-react": "^6.7.1",
    "fetch-mock": "^5.5.0",
    "istanbul": "1.0.0-alpha.2",
    "jasmine": "^3.1.0",
    "jest": "^17.0.2",
    "react-addons-test-utils": "~15.4.2",
    "react-native-mock": "~0.2.5",
    "react-test-renderer": "^16.3.2",
    "remote-redux-devtools": "^0.5.7",
    "rimraf": "^2.5.2"
  }

该行应如下所示:

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

但这通常不是您应该惹恼的事情。

Android oreo 是 only supported 来自 RN 0.51 + ,更新你的 react native,最新版本是 0.58,新版本 0.59 将带来 hooks 以响应 native 7u7