【问题标题】:GetCurrentLocation working in debug but not working in release apk in AndroidGetCurrentLocation 在调试中工作,但在 Android 的发布 apk 中不起作用
【发布时间】:2020-07-10 19:54:16
【问题描述】:

geolocator 包有问题,当我在调试模式下运行我的应用程序时,一切正常,但是当我构建应用程序并使用发布模式时,它卡在我的加载屏幕中,其中包含来自 geolocator 包的 getcurrentlocation。

Future<void> getCurrentLocation() async {
    try {
      Geolocator geolocator = Geolocator()..forceAndroidLocationManager = true;
      Position position = await geolocator.getCurrentPosition(
        desiredAccuracy: LocationAccuracy.low,
      );
      latitude = position.latitude;
      longitude = position.longitude;
    } catch (e) {
      print(e);
    }
  }

并且还添加到 android 清单访问。

【问题讨论】:

  • 您是否将发布密钥添加到 Firebase 控制台?
  • 我没有使用 firebase,我只使用来自 Flutter 包的 geolocator 插件

标签: android flutter dart plugins geolocation


【解决方案1】:

我在使用 Geolocator 包时遇到了同样的问题,我的许多用户无法访问他们的位置,也没有请求许可。

解决方案是改用location package

我无法找到这对我有用的确切原因,但我有一个正在生产的应用程序,将我的包更改为这对我有帮助。

【讨论】:

  • 我现在使用这个包,同样的问题在调试模式下运行良好,在发布模式下没有任何问题 ps:当应用程序启动时它需要权限但保持加载位置并且没有任何反应
【解决方案2】:

对于我的情况,我发现我必须在 AndroidManifest 中添加互联网权限。 xml

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

【讨论】:

    猜你喜欢
    • 2020-09-16
    • 2021-09-03
    • 1970-01-01
    • 2021-05-27
    • 2020-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-03
    相关资源
    最近更新 更多