简体   繁体   中英

Flutter - Android doesn't ask for permissions

I'm trying to get the current location of the device using the plugin location but Android never asks for permissions. I get this error:

Exception has occurred. PlatformException (PlatformException(PERMISSION_DENIED_NEVER_ASK, Location permission denied forever- please open app settings, null))

I have added the line below in every `AndroidManifest.xml´ file that I could find in the Android folder (no idea which one I should use actually, I found 3 of them)

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

I tried the plugin permission_handler to request them manually but still, no pop-up.

I'm completely lost and I find nothing similar on the net. Here is the code :

Future<LocationData> _getLocation() async {
  LocationData currentLocation;
  
  // returns a map with unreadable numbers which make no sense
  var t = await PermissionHandler()
      .requestPermissions([PermissionGroup.location]);
  
  // returns false
  var test = await location.requestPermission();

  try {
    currentLocation = await location.getLocation();
  } catch (e) {
    currentLocation = null;
  }
  return currentLocation;
}

Edit: I tried this on my device (OnePlus 6) and on an emulator (Pixel XL API 28). I've also tried to uninstall/reinstall the app.

I'm trying to get the current location of the device using the plugin location but Android never asks for permissions. I get this error:

Exception has occurred. PlatformException (PlatformException(PERMISSION_DENIED_NEVER_ASK, Location permission denied forever- please open app settings, null))

I have added the line below in every `AndroidManifest.xml´ file that I could find in the Android folder (no idea which one I should use actually, I found 3 of them)

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

I tried the plugin permission_handler to request them manually but still, no pop-up.

I'm completely lost and I find nothing similar on the net. Here is the code :

Future<LocationData> _getLocation() async {
  LocationData currentLocation;
  
  // returns a map with unreadable numbers which make no sense
  var t = await PermissionHandler()
      .requestPermissions([PermissionGroup.location]);
  
  // returns false
  var test = await location.requestPermission();

  try {
    currentLocation = await location.getLocation();
  } catch (e) {
    currentLocation = null;
  }
  return currentLocation;
}

Edit: I tried this on my device (OnePlus 6) and on an emulator (Pixel XL API 28). I've also tried to uninstall/reinstall the app.

I'm trying to get the current location of the device using the plugin location but Android never asks for permissions. I get this error:

Exception has occurred. PlatformException (PlatformException(PERMISSION_DENIED_NEVER_ASK, Location permission denied forever- please open app settings, null))

I have added the line below in every `AndroidManifest.xml´ file that I could find in the Android folder (no idea which one I should use actually, I found 3 of them)

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

I tried the plugin permission_handler to request them manually but still, no pop-up.

I'm completely lost and I find nothing similar on the net. Here is the code :

Future<LocationData> _getLocation() async {
  LocationData currentLocation;
  
  // returns a map with unreadable numbers which make no sense
  var t = await PermissionHandler()
      .requestPermissions([PermissionGroup.location]);
  
  // returns false
  var test = await location.requestPermission();

  try {
    currentLocation = await location.getLocation();
  } catch (e) {
    currentLocation = null;
  }
  return currentLocation;
}

Edit: I tried this on my device (OnePlus 6) and on an emulator (Pixel XL API 28). I've also tried to uninstall/reinstall the app.

I'm trying to get the current location of the device using the plugin location but Android never asks for permissions. I get this error:

Exception has occurred. PlatformException (PlatformException(PERMISSION_DENIED_NEVER_ASK, Location permission denied forever- please open app settings, null))

I have added the line below in every `AndroidManifest.xml´ file that I could find in the Android folder (no idea which one I should use actually, I found 3 of them)

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

I tried the plugin permission_handler to request them manually but still, no pop-up.

I'm completely lost and I find nothing similar on the net. Here is the code :

Future<LocationData> _getLocation() async {
  LocationData currentLocation;
  
  // returns a map with unreadable numbers which make no sense
  var t = await PermissionHandler()
      .requestPermissions([PermissionGroup.location]);
  
  // returns false
  var test = await location.requestPermission();

  try {
    currentLocation = await location.getLocation();
  } catch (e) {
    currentLocation = null;
  }
  return currentLocation;
}

Edit: I tried this on my device (OnePlus 6) and on an emulator (Pixel XL API 28). I've also tried to uninstall/reinstall the app.

add this

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

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