简体   繁体   中英

GetCurrentLocation working in debug but not working in release apk in Android

i have problem with geolocator package, when i run my app in debug mode everything works well but when i build the app and use the release mode it stuck in my loading screen which have the getcurrentlocation from geolocator package.

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);
    }
  }

and also add to android manifest access.

I faced the same problem with the Geolocator package, many of my users could not access their location and nor was the permission asked.

The solution was to use the location package instead.

I cannot site the exact reason why this worked for me but it i have an app in production, and changing my package to this helped me.

for my case i found that i must add internet permission into AndroidManifest. xml

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM