Abdelkader_Rezig
Abdelkader_Rezig

Reputation: 41

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.

Upvotes: 2

Views: 963

Answers (2)

Abdelkader_Rezig
Abdelkader_Rezig

Reputation: 41

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

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

Upvotes: 1

Abdul Malik
Abdul Malik

Reputation: 1188

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.

Upvotes: 1

Related Questions