Android 11-Even if "autoGrantPermissions" desired capability is set "true" location alert comes and it blocks automation

Hi ,

I am facing issue in Android 11, even if “autoGrantPermissions” desired capability is set “true” location alert comes and it blocks automation. Till Android 10 this capability was working fine but recently i have switched to Android 11. I tried changing appium version 1.17.0,1.18.0,1.19.1,1.20.2 but still issue is there. i even tried fullReset capabilty .Please suggest if someone has faced and applied any solution to it.!
#android 11 #appium 1.17.0 #appium 1.18.0 #appium 1.19.1 #appium 1.20.2 #realdevice #pixel5
Capture|282x409

check what state of location permission in settings?

HI. i am using browserstack for running automation suite. it is working fine on Android 10

appium uses command

adb -P 5037 -s YOUR_PHONE_ID shell 'settings delete global hidden_api_policy_pre_p_apps;settings delete global hidden_api_policy_p_apps;settings delete global hidden_api_policy'

to allow permissions. check locally with Android 11 phone. If problem still exist enter issue with logs.

Hi Aleksei, I am attaching parts of appium logs for your perusal.

2021-03-23 09:22:31:235 - [UiAutomator2] Starting ‘com.jch_hitachi.aircloudglobal’ directly on the device
2021-03-23 09:22:31:242 - [ADB] Cannot sort build-tools folders [“19.1.0”,“29.0.2”,“android-4.4.2”] by semantic version names.
2021-03-23 09:22:31:242 - [ADB] Falling back to sorting by modification date. Original error: Invalid Version: android-4.4.2
2021-03-23 09:22:31:243 - [ADB] Found 3 ‘build-tools’ folders under ‘/usr/local/.browserstack/android-sdk/’ (newest first):
2021-03-23 09:22:31:243 - [ADB] /usr/local/.browserstack/android-sdk/build-tools/19.1.0
2021-03-23 09:22:31:244 - [ADB] /usr/local/.browserstack/android-sdk/build-tools/29.0.2
2021-03-23 09:22:31:244 - [ADB] /usr/local/.browserstack/android-sdk/build-tools/android-4.4.2
2021-03-23 09:22:31:244 - [ADB] Using ‘adb’ from ‘/usr/local/.browserstack/android-sdk/platform-tools/adb’
2021-03-23 09:22:31:245 - [debug] [ADB] Running ‘/usr/local/.browserstack/android-sdk/platform-tools/adb -P 5037 start-server’
2021-03-23 09:22:31:250 - [AndroidDriver] Retrieving device list
2021-03-23 09:22:31:251 - [debug] [ADB] Trying to find a connected android device
2021-03-23 09:22:31:251 - [debug] [ADB] Getting connected devices
2021-03-23 09:22:31:257 - [debug] [ADB] Connected devices: [{“udid”:“0B021FDD40017Y”,“state”:“device”},{“udid”:“0B271FDD4006L9”,“state”:“device”},{“udid”:“0B281FDD4000TM”,“state”:“device”},{“udid”:“0B281FDD400522”,“state”:“device”},{“udid”:“0B281FDD400617”,“state”:“device”},{“udid”:“WCV5T19325001109”,“state”:“device”}]
2021-03-23 09:22:31:258 - [AndroidDriver] Using device: 0B281FDD4000TM
2021-03-23 09:22:31:259 - [ADB] Using ‘adb’ from ‘/usr/local/.browserstack/android-sdk/platform-tools/adb’
2021-03-23 09:22:31:259 - [debug] [ADB] Running ‘/usr/local/.browserstack/android-sdk/platform-tools/adb -P 5037 start-server’
2021-03-23 09:22:31:265 - [debug] [ADB] Setting device id to 0B281FDD4000TM
2021-03-23 09:22:31:265 - [debug] [ADB] Running ‘/usr/local/.browserstack/android-sdk/platform-tools/adb -P 5037 -s 0B281FDD4000TM shell getprop ro.build.version.sdk’
2021-03-23 09:22:31:286 - [debug] [ADB] Current device property ‘ro.build.version.sdk’: 30
2021-03-23 09:22:31:286 - [ADB] Getting device platform version
2021-03-23 09:22:31:286 - [debug] [ADB] Running ‘/usr/local/.browserstack/android-sdk/platform-tools/adb -P 5037 -s 0B281FDD4000TM shell getprop ro.build.version.release’
2021-03-23 09:22:31:301 - [debug] [ADB] Current device property ‘ro.build.version.release’: 11
2021-03-23 09:22:31:302 - [debug] [ADB] Device API level: 30
2021-03-23 09:22:31:302 - [UiAutomator2] Relaxing hidden api policy
2021-03-23 09:22:31:302 - [debug] [ADB] Running ‘/usr/local/.browserstack/android-sdk/platform-tools/adb -P 5037 -s 0B281FDD4000TM shell ‘settings put global hidden_api_policy_pre_p_apps 1;settings put global hidden_api_policy_p_apps 1;settings put global hidden_api_policy 1’’
2021-03-23 09:22:31:362 - [AndroidDriver] No app sent in, not parsing package/activity
2021-03-23 09:22:31:364 - [debug] [ADB] Running ‘/usr/local/.browserstack/android-sdk/platform-tools/adb -P 5037 -s 0B281FDD4000TM wait-for-device’
2021-03-23 09:22:31:374 - [debug] [ADB] Running ‘/usr/local/.browserstack/android-sdk/platform-tools/adb -P 5037 -s 0B281FDD4000TM shell echo ping’
2021-03-23 09:22:31:395 - [debug] [AndroidDriver] Pushing settings apk to device…
2021-03-23 09:22:31:396 - [debug] [ADB] Getting install status for io.appium.settings
2021-03-23 09:22:31:396 - [debug] [ADB] Running ‘/usr/local/.browserstack/android-sdk/platform-tools/adb -P 5037 -s 0B281FDD4000TM shell dumpsys package io.appium.settings’
2021-03-23 09:22:31:429 - [debug] [ADB] ‘io.appium.settings’ is installed
2021-03-23 09:22:31:430 - [debug] [ADB] Getting package info for ‘io.appium.settings’
2021-03-23 09:22:31:430 - [debug] [ADB] Running ‘/usr/local/.browserstack/android-sdk/platform-tools/adb -P 5037 -s 0B281FDD4000TM shell dumpsys package io.appium.settings’
2021-03-23 09:22:31:477 - [debug] [ADB] The version code of the installed ‘io.appium.settings’ is greater than the application version code (28 > 27)
2021-03-23 09:22:31:477 - [debug] [ADB] There is no need to downgrade ‘io.appium.settings’
2021-03-23 09:22:31:478 - [debug] [ADB] Getting IDs of all ‘io.appium.settings’ processes
2021-03-23 09:22:31:478 - [debug] [ADB] Running ‘/usr/local/.browserstack/android-sdk/platform-tools/adb -P 5037 -s 0B281FDD4000TM shell ‘pgrep --help; echo $?’’
2021-03-23 09:22:31:506 - [debug] [ADB] Running ‘/usr/local/.browserstack/android-sdk/platform-tools/adb -P 5037 -s 0B281FDD4000TM shell pgrep -f io\.appium\.settings’
2021-03-23 09:22:31:551 - [debug] [AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
2021-03-23 09:22:31:552 - [debug] [ADB] Running ‘/usr/local/.browserstack/android-sdk/platform-tools/adb -P 5037 -s 0B281FDD4000TM shell appops set io.appium.settings android:mock_location allow’
2021-03-23 09:22:31:595 - [debug] [Logcat] Starting logs capture with command: /usr/local/.browserstack/android-sdk/platform-tools/adb -P 5037 -s 0B281FDD4000TM logcat -v threadtime
2021-03-23 09:22:31:646 - [debug] [UiAutomator2] Forwarding UiAutomator2 Server port 6790 to 8201
2021-03-23 09:22:31:646 - [debug] [ADB] Forwarding system: 8201 to device: 6790
2021-03-23 09:22:31:646 - [debug] [ADB] Running ‘/usr/local/.browserstack/android-sdk/platform-tools/adb -P 5037 -s 0B281FDD4000TM forward tcp:8201 tcp:6790’
2021-03-23 09:22:31:662 - [debug] [ADB] Getting install status for io.appium.uiautomator2.server
2021-03-23 09:22:31:663 - [debug] [ADB] Running ‘/usr/local/.browserstack/android-sdk/platform-tools/adb -P 5037 -s 0B281FDD4000TM shell dumpsys package io.appium.uiautomator2.server’
2021-03-23 09:22:31:697 - [debug] [ADB] ‘io.appium.uiautomator2.server’ is installed
2021-03-23 09:22:31:697 - [debug] [ADB] Getting package info for ‘io.appium.uiautomator2.server’
2021-03-23 09:22:31:698 - [debug] [ADB] Running ‘/usr/local/.browserstack/android-sdk/platform-tools/adb -P 5037 -s 0B281FDD4000TM shell dumpsys package io.appium.uiautomator2.server’

As i can see from logs instead of “delete” in appium commands as conveyed by you it is appearing as “put”. Please let me know if anything else is required from my side. Thanks

  1. what is appium version? tested mine 1.20.2 and it uses ‘delete’
  2. also i have sdk tools 30.3.5

PS make issue i mean here -> https://github.com/appium/appium/issues

Hi Aleksei, I tried changing appium version 1.17.0,1.18.0,1.19.1,1.20.2 but still issue is there. Surprisingly, even if im using Android 10 it uses put in logs but permission is granted and no issue i observe running suite containing more than 250 test cases. I have created separate issue with both appium and device logs completely as suggested by you.