Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android - requestPermission not asking for permission #164

Closed
Robouste opened this issue Apr 13, 2019 · 7 comments
Closed

Android - requestPermission not asking for permission #164

Robouste opened this issue Apr 13, 2019 · 7 comments

Comments

@Robouste
Copy link

Robouste commented Apr 13, 2019

Describe the bug
When calling location.requestPermission(), Android does not ask for permission

Expected behavior
A popup should appears, asking for permission

Tested on:

  • OnePlus 6 (Android 9)
  • Pixel XL Emulator (API 28)

Additional logs

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

I also created this thread on Stackoverflow.

Future<LocationData> _getLocation() async {
  LocationData currentLocation;

  var test = await location.requestPermission();

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

When I go to the app Settings on my OP6, the permissions is greyed out, saying "no permissions requested"

@Lyokone
Copy link
Owner

Lyokone commented Apr 13, 2019

Hey, if there is no permission requested in your app's settings, are you sure to TargetSDK 28 in your build.gradle ?

@Robouste
Copy link
Author

Robouste commented Apr 13, 2019

I have two build.gradle files, one in root of app folder, and one in src folder.
I don't see this line in the first file, but I do see this in the second one :

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.mobile_app"
    minSdkVersion 16
    targetSdkVersion 28
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

@Lyokone
Copy link
Owner

Lyokone commented Apr 13, 2019

Okay it seems setup correctly. That's strange because when you add the plugin to your app, Flutter is supposed to automatically add the requested permission in your AndroidManifest.xml so it should appear in your app's settings.
Can you try to do a flutter clean to see if this is not a build problem ?

@Robouste
Copy link
Author

omg, you are a genius, I got the popup !

Thank you !

@Lyokone
Copy link
Owner

Lyokone commented Apr 13, 2019

Hehe glad it worked 😁

@Lyokone Lyokone closed this as completed Apr 13, 2019
@mike-gallego
Copy link

I'm glad I wasn't the only having this problem

@JamesMcIntosh
Copy link

Hi @Lyokone,
I just got stuck with this same problem. Could I recommend adding the flutter clean to the READM? I'm not sure how possible it would be but can you somehow check if the permission has been added to the AndroidManifest.xml?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants