Flutter-permission-handler: question of requestPermissions

Created on 17 Jul 2019  ·  16Comments  ·  Source: Baseflow/flutter-permission-handler

🐛 Bug Report

code like this :

Map<PermissionGroup, PermissionStatus> result = await PermissionHandler().requestPermissions(
          [PermissionGroup.microphone]
        );
print("***********);

when i accepted this request, nothing to happened. not execute print
when request permission again, error like this:

Caught error: PlatformException(ERROR_ALREADY_REQUESTING_PERMISSIONS, A request for permissions is already running, please wait for it to finish before doing another request (note that you can request multiple permissions at the same time

i don't know why

Version: 3.1.0

Platform:

  • [ ] :robot: Android
android question

Most helpful comment

i confirmed this bug exists in android platform

in my case, i check current permission status, after getting status, when i want request permission, this exception occured

Unhandled Exception: PlatformException(ERROR_ALREADY_REQUESTING_PERMISSIONS, A request for permissions is already running, please wait for it to finish before doing another request (note that you can request multiple permissions at the same time)., null)

All 16 comments

Have you added the permission to your AndroidManifest?

To access the microphone this should be:

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

See also the AndroidManifest.xml file in our example App.

Have you added the permission to your AndroidManifest?

To access the microphone this should be:

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

yes , i added it
permissions list like this:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.VIBRATE"/> <uses-permission android:name="android.permission.GET_TASKS"/>

The error you get the second time you request permissions indicates Android is still processing the initial request and hasn't returned an answer yet.

This makes sense because you mentioned that during the first attempt the call to the print("***********); statement is also not executed. Which should mean Dart is still awaiting the the call to the await PermissionHandler().requestPermissions([PermissionGroup.microphone]); method.

Are the permissions in de AndroidManifest.xml in the correct location? They should be a direct child of the <manifest> node.

Do you happen to see any other exceptions in you error log or console window?

The error you get the second time you request permissions indicates Android is still processing the initial request and hasn't returned an answer yet.

This makes sense because you mentioned that during the first attempt the call to the print("***********); statement is also not executed. Which should mean Dart is still awaiting the the call to the await PermissionHandler().requestPermissions([PermissionGroup.microphone]); method.

Are the permissions in de AndroidManifest.xml in the correct location? They should be a direct child of the <manifest> node.

Do you happen to see any other exceptions in you error log or console window?

yes, the location is right,
Caught error: PlatformException(ERROR_ALREADY_REQUESTING_PERMISSIONS, A request for permissions is already running, please wait for it to finish before doing another request (note that you can request multiple permissions at the same time)., null) I/flutter (20070): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7) I/flutter (20070): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33) I/flutter (20070): <asynchronous suspension> I/flutter (20070): #2 PermissionHandler.requestPermissions (package:permission_handler/src/permission_handler.dart:85:30) I/flutter (20070): <asynchronous suspension> I/flutter (20070): #3 _ChatState.createCall (package:BB/screens/chat/chat.dart:784:83) I/flutter (20070): <asynchronous suspension> I/flutter (20070): #4 _ChatState._buildBottomActionBar.<anonymous closure> (package:BB/screens/chat/chat.dart:934:28) I/flutter (20070): #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24) I/flutter (20070): #6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:365:11) I/flutter (20070): #7 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:312:7) I/flutter (20070): #8 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27) I/flutter (20070): #9 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart

this is all log of this bug

As mentioned this error is caused because Android is still trying to verify permissions for the first attempt (hence the error message "ALREADY_REQUESTING_PERMISSIONS").

So I am wondering if you see anything in the console or error log during the first attempt. If you want to start over you can uninstall the App and start debugging it again.

As mentioned this error is caused because Android is still trying to verify permissions for the first attempt (hence the error message "ALREADY_REQUESTING_PERMISSIONS").

So I am wondering if you see anything in the console or error log during the first attempt. If you want to start over you can uninstall the App and start debugging it again.

the log of first attempt like this:
Timeline: Activity_launch_request time:616550092 intent:Intent { act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.lbe.security.miui (has extras) } V/FA (22767): Recording user engagement, ms: 25047 V/FA (22767): Using local app measurement service V/FA (22767): Local AppMeasurementService is starting up V/FA (22767): Activity paused, time: 1291047750 V/FA (22767): Bound to IMeasurementService interface D/FA (22767): Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=25047, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-11060703441200034}] E/FirebaseInstanceId(22767): Google Play services missing or without correct permission. V/FA (22767): Connection attempt already in progress V/FA (22767): Connected to service V/FA (22767): Processing queued up service tasks: 2 V/FA (22767): Logging event: origin=auto,name=user_engagement(_e),params=Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=25047, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-11060703441200034}] D/FA (22767): Unable to get advertising id: com.google.android.gms.common.GooglePlayServicesNotAvailableException: com.google.android.gms.measurement.internal.zzeo.zzap(Unknown Source:9) V/FA (22767): Saving event, name, data size: user_engagement(_e), 69 V/FA (22767): Event recorded: Event{appId='com.flutter.example', name='user_engagement(_e)', params=Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=25047, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-11060703441200034}]} V/FA (22767): Upload scheduled in approximately ms: 3582964 V/FA (22767): Cancelling job. JobID: -2047570734 V/FA (22767): Scheduling upload with JobScheduler V/FA (22767): Scheduling job. JobID: -2047570734 V/FA (22767): Background event processing time, ms: 101 V/FA (22767): Inactivity, disconnecting from the service V/FA (22767): onUnbind called for intent. action: com.google.android.gms.measurement.START V/FA (22767): Local AppMeasurementService is shutting down V/FA (22767): Using local app measurement service V/PhoneWindow(22767): DecorView setVisiblity: visibility = 0, Parent = ViewRoot{53726b com.flutter.example/com.flutter.example.MainActivity,ident = 0}, this = DecorView@a2681c8[MainActivity] V/FA (22767): Local AppMeasurementService is starting up V/FA (22767): Bound to IMeasurementService interface V/FA (22767): Activity resumed, time: 1291064749 V/FA (22767): Connected to service V/FA (22767): Processing queued up service tasks: 1 I/zygote (22767): Do full code cache collection, code=120KB, data=111KB I/zygote (22767): After code cache collection, code=107KB, data=77KB

i confirmed this bug exists in android platform

in my case, i check current permission status, after getting status, when i want request permission, this exception occured

Unhandled Exception: PlatformException(ERROR_ALREADY_REQUESTING_PERMISSIONS, A request for permissions is already running, please wait for it to finish before doing another request (note that you can request multiple permissions at the same time)., null)

Normal in debug environment, no privilege prompt under release

Normal in debug environment, no privilege prompt under release
in my case, release version is ok, your platform is android or ios

i confirmed this bug exists in android platform

in my case, i check current permission status, after getting status, when i want request permission, this exception occured

Unhandled Exception: PlatformException(ERROR_ALREADY_REQUESTING_PERMISSIONS, A request for permissions is already running, please wait for it to finish before doing another request (note that you can request multiple permissions at the same time)., null)

it's ok in release version, you can try to build a release version

my problem solved in 3.2.1 version

I am having this error when i execute it even i gave permission in AndroidMainfest.Xml
PlatformException(permission, you don't have the user permission to access the camera, null)
plz help me out

I have this issue on v 4.0.0 with flutter 1.12.13+hotfix.5, but just on several devices

Hey, i have the solution about this issue, i can use this package in 5.0.0 or 5.1.1 lollipop on simulator with stock rom but in real life on Coolpad with Cool UI and Oppo with Color OS, this package cause exactly that error, so the solution just use this package on SDK android < 23 (M) instead.

i did it right in 2 steos

  1. check the android manifest you are working in it must be in android -> app -> main -> android manifest and check the permission format ..
  2. run flutter clean on terminal debug again
    your error will no longer will be there

Thankyou very much i solved it

On Thu, May 28, 2020 at 5:31 PM daman9699 notifications@github.com wrote:

i did it right in 2 steos

  1. check the android manifest you are working in it must be in android
    -> app -> main -> android manifest and check the permission format ..
  2. run flutter clean on terminal debug again
    your error will no longer will be there


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/Baseflow/flutter-permission-handler/issues/133#issuecomment-635317920,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ANHYMXG6H5L3TIIKYXSDPFDRTZKTDANCNFSM4IEO4WOA
.

Was this page helpful?
0 / 5 - 0 ratings