Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'adb devices' says unauthorized in TWRP

I am in TWRP recovery, version - 3.0.2-0 (multirom) Android Version - 5.1.1 OS - Cyanogen 12.1 - YOG4PAS1N0

1.

When I connect my phone via usb and try to run adb devices, I get -

List of devices attached
624225fe        unauthorized

And after that when I try any command, I get error -

adb shell
error: device unauthorized. Please check the confirmation dialog on your device.

No confirmation is being asked in my phone at this time.

When my device is on (not in recovery) and then when I connect it via usb then everything works fine (drivers already installed in my PC, android debugging enabled in my phone).

When I am in recovery then only it is throwing this error.

Also in the TWRP recovery there is an option of 'Terminal' in 'Advanced' and there I am able to run each command of adb and others.

How TWRP is not able to identify that permission has been granted already for adb. Is it a TWRP version issue?

  1. when I am trying adb pull /data/data/somefile when my phone is on (not in recovery), its saying error: device not found. Did not get this as I have already used this command many times before also.

Thanks.

like image 354
iamsmith41 Avatar asked Oct 28 '25 04:10

iamsmith41


2 Answers

If TWRP (and hence adbd) is built correctly as userdebug/eng build, it should never show unauthorized error. You can check the following properties using getprop:

ro.secure=0
ro.adb.secure=0
ro.debuggable=1

If not so, either use setprop tool or to make changes permanent, extract TWRP recovery.img using image kitchen and change/add the values in ramdisk/default.prop.

Sometimes adb doesn't work when MTP is disabled (due to difference of idVendor and idProduct values). For more details on these values and USB connections behavior, you may check /init.*usb.*rc files on your device. Re-enable MTP in mount options or set these properties:

persist.sys.usb.config=adb,mtp
sys.usb.config=adb,mtp

No confirmation is being asked in my phone at this time.

Confirmation dialogue only appears in running ROM, not in recovery but you may try to make adbd work with authorization. Mount /data so that /data/misc/adb/adb_keys can be read by ADB daemon. Copy contents of ~/.android/adbkey.pub (RSA key) from your PC to adb_keys on your phone. If file doesn't exist, create one and add public key. But be sure not to overwrite the file if it already contains some key from other PC.

Note that ~/.android/adbkey.pub is the path for Linux systems. On Windows, key exists at %userprofile%\.android\adbkey.pub or in rare cases at %windir%\system32\config\systemprofile\.android\adbkey.pub.

After making any changes restart adbd and adb:

~$ adb usb
~$ adb kill-server

RELATED: Storage location of “adb_keys”

like image 183
Irfan Latif Avatar answered Oct 30 '25 19:10

Irfan Latif


Using TWRP:

You must go to the advanced menu and use the "ADB sideload" functionality. It will allow you to use adb sideload commands (which you can use to flash zips). You should not be prompted for fingerprint authorization.

While phone is ON:

If your phone still doesn't connect while ON, be sure you have gone to the developer settings and enabled adb debug through USB.

In any case:

When the connection is not working it's always useful to restart the adb server:

adb kill-server
adb start-server

Final tip:

You can also transfer files from TWRP to your PC, using the built in File Manager.

like image 33
chech Avatar answered Oct 30 '25 17:10

chech



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!