You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have carefully read the documentation and verified I have added the required platform specific configuration.
Please select affected platform(s)
Android
iOS
Linux
macOS
Web
Windows
Steps to reproduce
Deny permission to make the app ask for the permission.
Expected results
Needed to deny or accept the permission.
Actual results
java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=109, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {.MainActivity}: java.lang.ArrayIndexOutOfBoundsException: length=2; index=-1
E/AndroidRuntime( 9691): at android.app.ActivityThread.deliverResults(ActivityThread.java:4845)
E/AndroidRuntime( 9691): at android.app.ActivityThread.handleSendResult(ActivityThread.java:4886)
E/AndroidRuntime( 9691): at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
E/AndroidRuntime( 9691): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime( 9691): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime( 9691): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
E/AndroidRuntime( 9691): at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime( 9691): at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime( 9691): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/AndroidRuntime( 9691): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 9691): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/AndroidRuntime( 9691): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/AndroidRuntime( 9691): Caused by: java.lang.ArrayIndexOutOfBoundsException: length=2; index=-1
E/AndroidRuntime( 9691): at com.odehbros.flutter_file_downloader.permissions.PermissionHandler.onRequestPermissionsResult(PermissionHandler.java:87)
E/AndroidRuntime( 9691): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onRequestPermissionsResult(FlutterEngineConnectionRegistry.java:746)
E/AndroidRuntime( 9691): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onRequestPermissionsResult(FlutterEngineConnectionRegistry.java:405)
E/AndroidRuntime( 9691): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onRequestPermissionsResult(FlutterActivityAndFragmentDelegate.java:912)
E/AndroidRuntime( 9691): at io.flutter.embedding.android.FlutterActivity.onRequestPermissionsResult(FlutterActivity.java:967)
E/AndroidRuntime( 9691): at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:8264)
E/AndroidRuntime( 9691): at android.app.Activity.dispatchActivityResult(Activity.java:8114)
E/AndroidRuntime( 9691): at android.app.ActivityThread.deliverResults(ActivityThread.java:4838)
E/AndroidRuntime( 9691): ... 11 more
// Test if location services are enabled.
serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
// Location services are not enabled don't continue
// accessing the position and request users of the
// App to enable the location services.
return Future.error(
'Please enable your location, it seems to be turned off.');
}
permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
if (permission == LocationPermission.denied) {
// Permissions are denied, next time you could try
// requesting permissions again (this is also where
// Android's shouldShowRequestPermissionRationale
// returned true. According to Android guidelines
// your App should show an explanatory UI now.
return Future.error('Location permissions are denied');
}
}
if (permission == LocationPermission.deniedForever) {
// Permissions are denied forever, handle appropriately.
return Future.error(
'Location permissions are permanently denied, we cannot request permissions. Please give permission and try again.');
}
final LocationSettings locationSettings = LocationSettings(
accuracy: LocationAccuracy.high,
timeLimit: Duration(seconds: 3),
distanceFilter: 100,
);
return await Geolocator.getCurrentPosition(
locationSettings: locationSettings);
} catch (e) {
return Future.error('Location can not be found');
}
}
Version
geolocator: ^13.0.2
Flutter Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.3, on macOS 15.2 24C101 darwin-arm64, locale en-NP)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] VS Code (version 1.87.2)
[✓] Connected device (5 available)
[✓] Network resources
• No issues found!
The text was updated successfully, but these errors were encountered:
I got the same problem. In my case, a few days ago upgrade a package to a new version and it seems this cause to crash when request the permission. I don't know the exact reason but it has to be some conflicts between packages. The packages is flutter_file_downloader (the solution was to revert the upgrade commit).
Please check the following before submitting a new issue.
Please select affected platform(s)
Steps to reproduce
Deny permission to make the app ask for the permission.
Expected results
Needed to deny or accept the permission.
Actual results
java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=109, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {.MainActivity}: java.lang.ArrayIndexOutOfBoundsException: length=2; index=-1
E/AndroidRuntime( 9691): at android.app.ActivityThread.deliverResults(ActivityThread.java:4845)
E/AndroidRuntime( 9691): at android.app.ActivityThread.handleSendResult(ActivityThread.java:4886)
E/AndroidRuntime( 9691): at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
E/AndroidRuntime( 9691): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime( 9691): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime( 9691): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
E/AndroidRuntime( 9691): at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime( 9691): at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime( 9691): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/AndroidRuntime( 9691): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 9691): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/AndroidRuntime( 9691): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
E/AndroidRuntime( 9691): Caused by: java.lang.ArrayIndexOutOfBoundsException: length=2; index=-1
E/AndroidRuntime( 9691): at com.odehbros.flutter_file_downloader.permissions.PermissionHandler.onRequestPermissionsResult(PermissionHandler.java:87)
E/AndroidRuntime( 9691): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onRequestPermissionsResult(FlutterEngineConnectionRegistry.java:746)
E/AndroidRuntime( 9691): at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onRequestPermissionsResult(FlutterEngineConnectionRegistry.java:405)
E/AndroidRuntime( 9691): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onRequestPermissionsResult(FlutterActivityAndFragmentDelegate.java:912)
E/AndroidRuntime( 9691): at io.flutter.embedding.android.FlutterActivity.onRequestPermissionsResult(FlutterActivity.java:967)
E/AndroidRuntime( 9691): at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:8264)
E/AndroidRuntime( 9691): at android.app.Activity.dispatchActivityResult(Activity.java:8114)
E/AndroidRuntime( 9691): at android.app.ActivityThread.deliverResults(ActivityThread.java:4838)
E/AndroidRuntime( 9691): ... 11 more
Code sample
Code sample
[Paste your code here]
Screenshots or video
Future determinePosition() async {
try {
bool serviceEnabled;
LocationPermission permission;
}
Version
geolocator: ^13.0.2
Flutter Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.3, on macOS 15.2 24C101 darwin-arm64, locale en-NP)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] VS Code (version 1.87.2)
[✓] Connected device (5 available)
[✓] Network resources
• No issues found!
The text was updated successfully, but these errors were encountered: