12

We are doing automation testing on mobile devices with Appium but testing fails because of the popup 'Allow USB debugging' even though the device is already connected through 'adb connect' and 'adb devices.' I already checked the 'Always allow from this computer' but sometimes the popup would occur causing the test to fail and sometimes it will pass when it will not show up. Can someone enlighten me on how to address this issue?

3

In my case, I was continually getting prompted with one fingerprint. I revoked all debugging permissions and next time the dialog popped up, I noticed the fingerprint had changed. So far I haven't been prompted again.

So: try revoking all debug permissions and then allowing USB debugging again.

1

One possibility for this problem may be located on PC side: May be you are running multiple adb daemons with different private keys. The private key is used for identifying the "this computer".

The relevant files that contain the cryptographic identify are adbkey and adbkey.pub located in the folder .android folder within the user home directory:

  • Windows: C:\users\%username%\.android\
  • Linux: ~/.android/

Make sure those two files don't change. Some other software may overwrite these files.

Another possibility would be a problem on device side that e.g. the adb server crashes and losses the data on previous authorized computers. Or it may be a bug in adb that causes the identification of the computer to fail.

3
  • Problem with the USB port or the the cable can also does that. It used to be the case with my Nexus 6 (bad port, bad cable) but this is unlikely the case for OP though.
    – Firelord
    Feb 14 '19 at 16:55
  • Thank you @Robert for this one. I will sure to check it on my side. But i am using my pc that is connected to the mobile device with a usb cable. Regarding on the another possibility, should i have a checker to check every execution whether the RSA key of the computer is already authorized to the mobile device then add it otherwise?
    – Gel
    Feb 15 '19 at 3:07
  • Yes @Firelord, I also think that it may be because of the usb cable that caused the loss of connection but I have a checker to execute adb devices to check if there's a connection before executing the test. It says that it is connected but it will fail in creating the mobile capabilities in Appium. So that's what I am wondering about as to why it failed when it says that it is already connected. Then it also prompts the 'Allow usb debugging' even though I already checked the 'Always allow in this computer'
    – Gel
    Feb 15 '19 at 3:11
1

Change the USB cable

My proposed solution is not general, but may work in in some special cases.

Here is my story: Once I used an old USB cable for connecting my 10 smartphones to my computer. It worked well for 9 phones, except for 1 phone where “Allow USB debugging” kept on popping. Then I changed to a newer USB cable, and the problem went away.

1
  • I was getting this every few minutes. I switched to a different USB cable and haven't gotten it in a couple of days. We'll see if it lasts but definitely worth a quick shot. Thanks! Oct 28 '21 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.