I have included in my flutter page a simple GoogleMap component only to see if it works but I can't resolve this problem. I compile the application and when I navigate to the page I get the following error in the console:
"E/GoogleMapController( 3376): Cannot enable MyLocation layer as location permissions are not granted"
I can see the component but I'm not able to see the map (see the image):
Added configurations:
//(AndroidManifest.xml)
<meta-data android:name="com.google.android.geo.API_KEY" android:value="apikey"/>
//(pubspec.yaml)
google_maps_flutter: ^0.5.0
EDIT - SOLUTION
Add the permission package to request permission. You can install this package to manage your permissions: https://pub.dartlang.org/packages/permission
Open your phone's Settings app. Under "Personal," tap Location access. At the top of the screen, turn Access to my location on or off.
May be your API key is not setup properly and granted location service access.
Check and enable these services
As of December 2019 I was not successful with using the permissions plugin. Even after adding the necessary manifest data and upgrading the project to Android API 29
it still returned, PermissionStatus.notAgain
.
What did work was adding the permissions_handler plugin with the manifest data they provided (just the location part). Also, upgrading the Android API to 29 as detailed here and changing the compileSDKVersion
and targetSdkVersion
in android/app/build.gradle
to 29
.
Mainfest data, just before the <application>
tag in directory android/app/src/main/AndroidManifest.xml
<!-- Permissions options for the `location` group -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
Restart the IDE to make sure all those changes take effect. Then to request the permission in your app:
import 'package:permission_handler/permission_handler.dart';
void setPermissions() async{
Map<PermissionGroup, PermissionStatus> permissions =
await PermissionHandler().requestPermissions([PermissionGroup.location]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With