Are you using geolocation in your Flutter Android App, or fetching Longitude or Latitude from a GPS device on the app? You may get a "No location permissions are defined in the manifest" error while fetching, see the solution below:
E/flutter ( 8937): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception:
No location permissions are defined in the manifest. Make sure at
least ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION are defined in the manifest.
E/flutter ( 8937): #0 MethodChannelGeolocator.checkPermission
(package:geolocator_platform_interface/
src/implementations/method_channel_geolocator.dart:48:7)
E/flutter ( 8937): <asynchronous suspension>`
E/flutter ( 8937): #1 _HomeState.checkGps (package:testapp/main.dart:38:26)
E/flutter ( 8937): <asynchronous suspension>
E/flutter ( 8937):
Activating Dart DevTools...
To solve this error, add the Location permission in AndroidManifest.xml file located at android/app/src/main/AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Your XML file may look like:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.testapp">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:label="testapp"
android:icon="@mipmap/ic_launcher">
You have to add ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION permission to use Geolocation in Android App.
After adding these permissions on AndroidManifest.xml file, hit the command below to clear the build cache of the Flutter app.
flutter clean
Now, an error will not appear, run the app to test. This is the way to solve "No location permissions are defined in the manifest" error in Flutter Android App.
Please Wait...
No any Comments on this Article