react native expo app ACCESS_BACKGROUND_LOCATION needs to be added to the manifest Problem

aym*_*mon 3 javascript android location react-native expo

我正在使用托管流程构建一个博览会应用程序(所以我无法直接访问android中的清单),我确实阅读了甚至记住了文档,它说我需要向android添加权限。我的 app.config.json 文件中的权限如下:

"android": {
  "permissions": [
    "ACCESS_BACKGROUND_LOCATION",
    "ACCESS_COARSE_LOCATION",
    "ACCESS_FINE_LOCATION"
  ]
},
Run Code Online (Sandbox Code Playgroud)

它仍然告诉我同样的事情,尽管根据文档,这是我需要做的唯一一件事来包含许可。但由于某种原因,要么Android设备忽略了这一点,要么expo没有将其添加到他们在后台构建的清单中,或者出于某种原因,应用程序的行为就像我没有将这些行添加到配置文件中一样。

我尝试过的事情:

  • 我尝试了多种方法,包括删除精细位置权限(因为有人说新的 Android 更新只接受一种位置权限;精细位置或后台位置)。这当然行不通。

  • 构建我的应用程序的独立版本(因为有人说 Expo go 不允许在 Android 上进行后台定位)

  • 我在 github 和 expo 论坛上看到了多个关于此问题的问题,最引人注目的是:

1-在 github 上提出的问题
2-在 expo 论坛上提出的问题

我当然也阅读了以下内容

博览会权限文档
博览会上的 Android 配置文档

我用来请求许可的代码:

    try {
// at the following line it just breaks and jumps to the catch block
      const { status } = await Location.requestBackgroundPermissionsAsync();
      console.log(
        "@@@@@@@@@@@@@@@@@@@@@@ requestBackgroundPermissionsAsync @@@@@@@@@@@@@@@@@@@@@@"
      );
      console.log(status);
      console.log(
        "@@@@@@@@@@@@@@@@@@@@@@ requestBackgroundPermissionsAsync @@@@@@@@@@@@@@@@@@@@@@"
      );
      if (status === "granted") // ... the rest of the code

    } catch (error) {
      console.log(error);
    }
Run Code Online (Sandbox Code Playgroud)

该代码只是在这一行出现错误并告诉我以下内容:

    You need to add `ACCESS_BACKGROUND_LOCATION` to the AndroidManifest.
at node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:103:50 in promiseMethodWrapper
at node_modules/@unimodules/react-native-adapter/build/NativeModulesProxy.native.js:15:23 in moduleName.methodInfo.name
at node_modules/expo-location/build/Location.js:142:7 in requestBackgroundPermissionsAsync
at node_modules/expo-location/build/Location.js:142:22 in requestBackgroundPermissionsAsync
at screens/home/GoToLocation.tsx:156:25 in onGoToLocation
at http://192.168.8.102:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&minify=false:191029:39 in onGoToLocation
at node_modules/react-native/Libraries/Pressability/Pressability.js:691:17 in _performTransitionSideEffects
at node_modules/react-native/Libraries/Pressability/Pressability.js:628:6 in _receiveSignal
at node_modules/react-native/Libraries/Pressability/Pressability.js:524:8 in responderEventHandlers.onResponderRelease
Run Code Online (Sandbox Code Playgroud)

问题是:这是否像世博会上的一个错误,他们需要修复它,还是我做错了?如果我做错了什么。请帮忙。

aym*_*mon 5

经过几天的斗争,结果发现这是新版本的 expo go 应用程序 2.22.3 中的一个错误,它根本不读取或注册此类权限。所以我只是降级到版本 2.21.5,它工作得很好。

世博会的一位维护者在 github 上提出的问题上证实了这一点

github问题和确认

无论如何,他们似乎正在努力解决这个问题,但在修复之前,如果您正在使用 Android 进行测试,请使用旧版本的应用程序。