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

437

Solution 1

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

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

Solution 2

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.

Share:
437
Abdelkader_Rezig
Author by

Abdelkader_Rezig

Updated on December 22, 2022

Comments

  • Abdelkader_Rezig
    Abdelkader_Rezig over 1 year

    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.

    • Payam Asefi
      Payam Asefi almost 4 years
      did you add release key to firebase console?
    • Abdelkader_Rezig
      Abdelkader_Rezig almost 4 years
      i m not using the firebase, i m using only geolocator plugin from flutter packages
  • Abdelkader_Rezig
    Abdelkader_Rezig almost 4 years
    i used now this package, same issue works well on debug mode and nothing in release mode ps: when app starts it demands permission but keep loading location and nothing happen