Android ADB devices unauthorized - android

Configuration:
Windows 8.1
ADB version: 1.0.32
Smartphone: Oneplus One
Problem
I installed the Samsung drivers as it is said to do. When I run the ADB devices command, it said unauthorized.
Already tried:
I've done everything that'd been said on this post: https://stackoverflow.com/a/25546300/1848376
But the problem is that I don't get a prompt on the phone to tell me I must accept the connection.
When I run the command adb shell, here is the answer:
error: device unauthorized.
This adbd's $ADB_VENDOR_KEYS is not set; try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
I did "adb kill-server", but it didn't change anything. Why?

Try Revoke USB DEBUGGING Authorization.
Enable USB debugging again.
It worked.

Thankgod xda developers exist : http://forum.xda-developers.com/verizon-lg-g3/help/unable-to-access-adb-t2830087
Just had to delete adbkey file in C:Users/$Name/.android adbkey.pub was missing.
Restart after this and both files are there.
If this does not work :
- Try Revoke USB DEBUGGING Authorization.
- Enable USB debugging again.

In sequence:
adb kill-server
in your DEVICE SETUP, go to developer-options end disable usb-debugging
press REVOKE USB debugging authorizations, click OK
enable usb-debugging
adb start-server

I removed the following files from the ~/.android folder:
adbkey
adbkey.pub
I disabled and enabled ADB within device and now it works...

in Developer options,
Enable USB debugging.
Give a authorization.
(if there is no a Developer option menu, you have to click 3 times build number of Phone State menu to be developer. you can sse a developer option menu.)

Delete existing adbkeys
OR
Rename adbkeys
Best practise is to rename the keys because it provides backup.
cd ~/.Android
mv adbkey adbkey2
mv adbkey.pub adbkey.pub2
Next stop & start the server
cd ~/Android/Sdk/platform-tools
Locate the device
/Android/Sdk/platform-tools$ ./adb devices
/Android/Sdk/platform-tools$ ./adb kill-server
/Android/Sdk/platform-tools$ ./adb start-server
Then, stop the emulator Open AVD manager, click on the down arrow, then click on wipe data
Restart the emulator. Then everything works fine :)

This worked for me
1- Go to ~/.android/ and remove “adbkey”
2- Disconnect USB connection
3- adb kill-server
4- Revoke USB debugging authorizations (in developer option)
5- Reconnect the device to the Ma
6- adb devices

Try this uncheck the "verify apps via USB" in developer options and then turn on and off the "USB Debugging". It works with me.

Ensure that you have accepted the pressed the "ok" button when it is asking it is showing the fingerprint of the device after connecting through usb to your PC.

In Android studio, Run menu > Run shows OFFLINE ... for the connected device.
Below is the procedure followed to solve it:
(Read the below note first) Delete the ~/.android/adbkey (or, rename to ~/.android/adbkey2, this is even better incase you want it back for some reason)
Note: I happened to do this step, but it didn't solve the problem, after doing all the below steps it worked, so unsure if this step is required.
Run locate platform-tools/adb
Note: use the path that comes from here in below commands
Kill adb server:
sudo ~/Android/Sdk/platform-tools/adb kill-server
You will get a Allow accept.. message popup on your device. Accept it. This is important, which solves the problem.
Start adb server:
sudo ~/Android/Sdk/platform-tools/adb start-server
In Android studio, do Run menu > Run again
It will show something like Samsung ... (your phone manufacture name).
Also installs the apk on device correctly this time without error.
Hope that helps.

None of the methods listed on this page worked for me; specifically:
I had an issue where the Settings app would crash when selecting Revoke USB debugging authorizations
I was running LineageOS 14 x86_64
I was using ADB over network
The /data/misc/adb contained no adb_keys file
Removing my local ~/.android/adbkey did not help either
I had root access from the local terminal
I was not getting any confirmation dialog
adb: error: failed to get feature set: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
- waiting for device -
In the end, I found a very useful post here that suggested to manually put the contents of ~/.android/adbkey.pub inside the /data/misc/adb/adb_keys file.
They suggested one of these two methods:
From another working device, copy the adb_keys file into your computer:
# On the other Android device
cp /data/misc/adb/adb_keys /sdcard
# From your computer
adb pull /sdcard/adb_keys .
Then put the working adb_keys file into the problematic Android device's sdcard (using Web or MTP) named as adb_keys, then copy the file into the correct path:
# On the problematic device
cp /sdcard/adb_keys /data/misc/adb/adb_keys
The other method is to simply copy your machine's adbkey.pub from the ~/.android/ directory, and put it into the problematic Android device's sdcard (using Web or MTP) named as adb_keys, then copy the file into the correct path:
# On the problematic device
cp /sdcard/adbkey.pub /data/misc/adb/adb_keys
(Note: there's a similar answer on SO that goes into further details for this method.)
Since I was running a web server on my computer, and I had curl installed on Android, I su'ed from the terminal and ran the following on my Android device:
cd /data/misc/adb
curl 192.168.1.35:8080/adbkey.pub > adb_keys
Killed the adb daemon (using adb kill-server) and BAM! The adb shell worked fine, like it should have been from the beginning.
Hopefully, the method described here works for you as it did for me.

First Remove the adbkey and adbkey.pub from the .android directory in your Home directory.
Make .android directory in your home with 710 permissions: $ chmod 710 .android/ and ownership as: chown -R <user>:<user> .android/. Ex:
$ chmod 710 .android/
$ chown -R ashan:ashan .android/
Go to developer options in your mobile and tap option Revoke USB debugging authorizations
Turn off all USB Debugging and Developer Options in the device and disconnect the device from your machine.
Connect the device again and at first turn on the Developer Options. Then Turn on the USB debugging.
At this point in your mobile, you will get a prompt for asking permission from you. Note: you must check the checkbox always accept from this …. option and click ok.
Now in you machine, start the adb server: adb start-server.
Hopefully when you issue the command: adb devices now, you will see your device ready authorized.

I was hit by this problem, too. I'm using my custom build of AOSP on Nexus 5X. I've added a single line in build/core/main.mk:
diff --git a/core/main.mk b/core/main.mk
index a6f829ab6..555657539 100644
--- a/core/main.mk
+++ b/core/main.mk
## -362,6 +362,8 ## else # !enable_target_debugging
ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0
endif # !enable_target_debugging
+ADDITIONAL_DEFAULT_PROPERTIES += ro.adb.secure=1
+
## eng ##
ifeq ($(TARGET_BUILD_VARIANT),eng)
Now adb shell works fine
Those materials are useful (Chinese articles): http://www.voidcn.com/blog/kc58236582/article/p-6335996.html, http://blog.csdn.net/fanmengke_im/article/details/28389439

Try deleting the adbkey file from C/.android folder
and then run the commands as
mentioned above i.e.
adb kill-server, adb start-server and adb devices
.

Your app is being detected as some harmful program.
Turn off "Verify apps over USB" option. It's in the same view as "USB debugging".

All you need is to authorize debug mode.
1. make sure your Device is connected to your PC.
2. Allow authorized for debug mode via Android-Studio by going to
Run -> Attach debugger to Android process
than you will see the pop up window for allow debug mode in your Device, press OK. done.
i hope it help to someone.

I had the same problem after reinstalled my android studio. Here's what I did to make my adb work again:
-path to C:\Users\User\AppData\Local\Android\sdk\platform-tools
-Shift+r.click and start command from here instead.

for anyone encountering this later this may also help. I encountered this exact issue trying to use adb from a user command prompt and the answers above did not help, but the problem went away with an "adb kill-server" when running in an administrator command prompt.

This worked for me:
rm ~/.android/adbkey.pub
sudo ./adb kill-server
sudo ./adb start-server
sudo ./adb -s emulator-5554 install ~/apk_to_install.apk
I'm not sure if is a good idea run adb with sudo privileges,but it was the only way I get it works. Regards.

I got this as root when as a non-root user I was getting permissions errors trying to connect to custom recovery (Philz). so I killed adb server, copied the .android subdirectory of my user account into /root, chowned -R to root.root, and restarted adb server. I'm in!

Disconnect USB between PC and device
Stop adb server by entering "adb kill-server" in command window
On device use "Revoke USB debugging authorizations" in "Developer Options"
On PC delete "adbkey" file in user directory, for example "C:\Users\Amit\.android"
Reconnect the device to the PC
Open a command window and enter "adb devices". Watch the device's screen for any Authorization message and allow the connection.

I suppose you have enabled On-device Developer Options in your smartphone? If not you can take a look at the steps provided by Android, http://developer.android.com/tools/device.html#developer-device-options

For FIRE STICK 4K it actually says in the dialog:
Otherwise check for a confirmation dialog on your device
Indeed on the TV in the other room there was a confirmation dialog. Doh'!

I had this problem and it wasnt solved by the deleting of any keys (at least deleting them didnt fix it, maybe had an effect after i did fix it though)
I actually had a discrepancy between my sdk-tools version and my Android Studio version. After updating my tools it still didnt work, but after updating AS (to 1.4) everything worked fine again.
Always update both sdk-tools and AS version together ;)

Related

Android ADB: Device unauthorized trying to connect to a port-forwarded remote emulator

Background:
I recently upgraded to an AMD processor and found that the Android device emulator was complaining about not having hardware acceleration. (This is an issue for another question). My old Intel computer worked fine, so I decided to run the emulator on the old Intel PC (emu-pc) and use my new AMD computer (dev-pc) to code.
Problem:
I wasn't able to directly have the emulator expose its ports on the emu-pc to connect to via adb on the dev-pc (again an issue for another question), so I installed the Windows 10 OpenSSH server (Microsoft instructions) and connected to it from my dev-pc, forwarding the proper ADB ports:
ssh {you}#<{remote ip} -L 5554:localhost:5554 -L 5555:localhost:5555
I then tried connecting to the remote emulator via adb:
adb connect localhost
I was met with
$ ./adb devices
List of devices attached
localhost:5555 unauthorized
I've tried a few of the posts stating you should disable and re-enable USB debugging or revoke all the USB debugging authorization or use the "Wipe Data" option in the AVD Manager. None of these worked. I also tried messing with the adbkeys on the emulator under /data/misc/adb/adbkeys but I get permission denied trying to do anything to that file. (I also can't ls it via an adb shell)
Any ideas?
I found something that worked for me. I was able to telnet to the emu-pc via port 5554, where I tried to auth on the Android console. The login message said:
Android Console: type 'auth <auth_token>' to authenticate
Android Console: you can find your <auth_token> in
'C:\Users\exile57\.emulator_console_auth_token'
I found that file and was able to log in. This made me think that the emulator thinks the connection is coming from the emu-pc, yet the keys that I was using were generated on the dev-pc. I found the keys on emu-pc in C:\Users\[your user]\.android as adbkey and adbkey.pub. I copied those to the dev-pc, killed the adb server, disconnected all devices, then tried reconnecting:
$ ./adb disconnect
./adb kill-server
./adb connect localhost
After a bit, I was able to connect and drive the device over adb:
$ ./adb devices
List of devices attached
localhost:5555 device
NOTE I'm not sure this is the whole story, as when testing this out for this answer, I deleted the dev-pc's adbkey and adbkey,pub and was still able to reconnect, so that seems a bit strange. It worked for me, but be aware, I'm not sure the mechanism.
In Android studio, Run menu > Run shows OFFLINE ... for the connected device.
Below is the procedure followed to solve it:
(Read the below note first) Delete the ~/.android/adbkey (or, rename to ~/.android/adbkey2, this is even better incase you want it back for some reason)
Note: I happened to do this step, but it didn't solve the problem, after doing all the below steps it worked, so unsure if this step is required.
Run locate platform-tools/adb
Note: use the path that comes from here in below commands
Kill adb server:
sudo ~/Android/Sdk/platform-tools/adb kill-server
You will get a Allow accept.. message popup on your device. Accept it. This is important, which solves the problem.
Start adb server:
sudo ~/Android/Sdk/platform-tools/adb start-server
In Android studio, do Run menu > Run again
It will show something like Samsung ... (your phone manufacture name).
Also installs the apk on device correctly this time without error.
Hope that helps.
Here is how I did it:
First you need to run the emulator on the host computer. I used Android Studio and I had to close it because I noticed that the adb process kept spawning.
Start port-forwarding using SSH in the development computer.
ssh -L 5554:localhost:5554 -L 5555:localhost:5555 user#emulator-host-ip
copy adbkey and adbkey.pub files found at: C:\Users\[your user]\.android from the host computer to the development computer. this step should get ride of the unauthorized problem
in the development computer kill the adb server and lookup connected devices:
$ ./adb kill-server
$ ./adb devices
List of devices attached
localhost:5555 device

Set adb vendor keys

EDIT: I figured out the problem, i think. ADB found out I wasn't on the latest updates (at&t released a stagefright udpate and i didnt know) so ADB didn't let me debug. Everything is fine now.
I have been debugging my app on an AT&T HTC One M8 for about a month. Suddenly today when I plugged in my phone, I didn't get the authorization popup. After an hour of troubleshooting, I found the problem, but not a solution.
This is the error i get in Android Studio 1.3.1:
device unauthorized.
This adbd's $ADB_VENDOR_KEYS is not set; try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
I googled $ADB_VENDOR_KEYS but to no avail.
Information:
Phone: AT&T HTC One M8 running 5.0.1 (API 21)
Android Studio version 1.3.1 build 141.2135290
JDK Version: 1.8.0_60
How can I get the popup again? I need to debug my app
In this case what you can do is :
Go in developer options on the device
Uncheck "USB Debugging" then check it again
A confirmation box should then appear
I tried almost anything but no help...
Every time was just this
➜ ~ adb devices
List of devices attached
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
aeef5e4e unauthorized
However, I've managed to connect my device!
This is the step-by-step tutorial.
Remove existing adb keys on PC:
$ rm -v .android/adbkey .android/adbkey.pub
Remove existing authorized adb keys on device, the path is /data/misc/adb/adb_keys
Now create a new adb keypair
adb I 47453 711886 adb_auth_host.cpp:220] generate_key '.android/adbkey'
adb I 47453 711886 adb_auth_host.cpp:173] Writing public key to '.android/adbkey.pub'
Manually copy from PC .android/adbkey.pub (public key) to Device on path /data/misc/adb/adb_keys
Reboot the device and check adb devices :
➜ ~ adb devices
List of devices attached
aeef5e4e device
Permissions of /data/misc/adb/adb_keys are (766/-rwxrw-rw-) on my device
look at this url Android adb devices unauthorized else briefly do the following:
look for adbkey with not extension in the platform-tools/.android and delete this file
look at C:\Users\*username*\.android) and delete adbkey
C:\Windows\System32\config\systemprofile\.android and delete adbkey
You may find it in one of the directories above. Or just search adbkey in the Parent folders above then locate and delete.
If you have an AVD, this might help.
Open the AVD Manager from Android Studio. Choose the dropdown in the right most of your device row. Then do Wipe Data. Restart your virtual device, and ADB will work.
I tried every method listed here and in Android adb devices unauthorized
What eventually worked for me was the option just below USB Debugging 'Revoke auths'
I had the same problem running Ubuntu 18.04. I tried multiple solutions but my device (OnePlus 5T) was always unauthorized.
Solution
Configure udev rules on Ubuntu. To do this, just follow the official documentation:
https://developer.android.com/studio/run/device
The idVendor of my device (OnePlus) is not listed. To get it, just connect your device and use lsusb:
Bus 003 Device 008: ID 2a70:4ee7
In this example, 2a70 is the idVendor.
Remove existing adb keys on Ubuntu:
rm -v ~/.android/adbkey* ~/.android/adbkey ~/.android/adbkey.pub
'Revoke USB debugging authorizations' on your device configuration (developer options).
Finally, restart the adb server to create a new key:
sudo adb kill-server
sudo adb devices
After that, I got the authorization prompt on my device and I authorized it.
Sometimes you just need to recreate new device

Insufficient permissions for device in Android Studio Workspace running in openSUSE 13.2

I have a rooted Motorola Defy+ running a Cyanogenmod v11 custom ROM (nightly build) created by Quarx. Using Android Studio Workspace,(ASW) v.1.1.0, when I try and debug on this device, I get
????????????[null]
listed in the Choose Device window, with the Logcat window showing
insufficient permissions for device
I would really like to use this device and ROM for debugging purposes.
When I enter lsusb from the command line I get,
Bus 002 Device 002: ID 22b8:431d Motorola PCS
This is the correct device id for Motorola units. I have installed 51-android.rules and 71-android.rules in /etc/udev/rules.d/ with the correct Motorola ids in these files.
I've also tried Revoke USB debugging authority, from Developer Options on the device, with no luck.
I have not tried running ASW as root hoping that there might be another option; is there?
Update: I was able to get in and access ADB by
uvachem-gsmith2:/home/greg/Android/Sdk/platform-tools # ./adb
I then did a kill server, did an SU to root user and restarted the server. I then tried to connect to the device from Android Studio. Got a message on the device about accepting the RSA key from the PC, said "Yes" and then was able to deploy the app to the device. So back to my original question, Is there another way to access this device without logging in as root? It seems as if there is a permission issue on the phone file system that is preventing this...
Update #2 The core problem here was a permission thing. Even though running ADB as root will allow access to the rooted Android device, a better solution is to change permissions in the udev file for this device...resetting 664 to 666, (see answer below). This allows the PC to access the file system on the device.
I had this while using a Linux machine with a Nexus 4 running Android 5.1
The fix was to enable both 'debug over USB' and 'connect as MTP'. The opposite is true when using the same device and Android Studio and adb on OSX though - to allow Android Studio to recognise the handset, I need to disable 'connect as MTP'.
I found a simple answer that worked for me:
adb kill-server
sudo adb start-server
sudo adb devices
You will find your device then.
Reference: http://itsfoss.com/fix-error-insufficient-permissions-device/
It's simple.
Just change your USB mode to File Transfer mode then it works.
Android 8
MTP is no longer available. On my android 8 "Transfer Files" option did not work.
"Transfer photos PTP" Is worked, and Studio showed the device name.
Steps on your cell phone
Open the developer options
Enable USB debugging.
change USB connection to PTP
Steps on Linux
on console run sudo usermod -aG plugdev $LOGNAME
Android 9
With Android 9 use the option File Transfer.
Changing permissions in this line from /etc/udev/rules.d/51-android.rules,
#Motorola
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0664", GROUP="plugdev"
to,
#Motorola
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666", GROUP="plugdev"
resolves this issue in a manner that DOES NOT require running adb as root.
IN my phone Symphony W75,
in option USB computer connection-> selecting Connect as Media device(MTP) has solved the problem.
Long to short,
I had the same problem with a Prestigio PMP5570C tablet,
all you have to do is to confirm on your tablet that you want to copy data to/from your computer (what i forgot), and add the 2 lines that #portsample wrote.
You can find the idVendor of your device typing
lsusb
in UBUNTU 12.04, then you get:
Bus 001 Device 011: ID 2207:0010,
where 2207 is your vendor id.
Summed up the question and answer...
I updated my device (Nvidia Shield) that was previously connecting fine, so I knew that the PC setup is correct already. The developer settings seem to have a new layout on Android 7.0.
It is under Settings > Preferences > Developer options > Networking > Select USB configuration
Here, I needed to select PTP and everything works fine again:
Enable USB debugging
Use USB to transer file
This procedure solves the problem for me:
- On the Android device, drag the top menu and select "USB for file transfer"
- Press "Run" again
Go to Developer Options -> Default USB Configurations and Change to PTP
Run these two commands in terminal
sudo adb kill-server
sudo adb start-server
Should Work!
I made a script for this error. For me it works fine in Fedora 28, but it should work in many Linux distributions.
Just create a file with the content of the selfexpanied script. I called it usbDebbugingAndroidStudio.sh
Give him execution permission with: chmod +x usbDebbugingAndroidStudio.sh
And run it: sudo ./usbDebbugingAndroidStudio.sh
After that check the list displayed by the command lsusb and introduce the Id of
your device.
For example:
My output was: Bus 006 Device 002: ID 05c6:9091 Qualcomm, Inc.
So I type 05c6 and press enter.
The script:
#!/usr/bin/env bash
#This script configure Android Debug Bridge permissions to solve the following
#error: com.android.ddmlib.AdbCommandRejectedException: insufficient permissions for device
#This error is produced when you try to install an APK from Android Studio in your device.
#You can check the vendorId here:
#https://developer.android.com/studio/run/device#setting-up
#If your device's brand isn't listed check the info displayed by the command lsusb
lsusb
#My output was:
#Bus 006 Device 002: ID 05c6:9091 Qualcomm, Inc.
#The id for this line is 05c6
echo -n "Enter the id of your mobile device: "
read usbProviderId
cd /etc/udev/rules.d/
sudo touch 51-android.rules
(
sudo cat << _EOF_
SUBSYSTEM=="usb", ATTR{idVendor}=="$usbProviderId", MODE="0666", GROUP="plugdev"
_EOF_
) | sudo tee 51-android.rules
#Give read and write permissions to the file
sudo chmod a+r /etc/udev/rules.d/51-android.rules
#Kill the Android Debug Bridge server to restart it
cd $HOME/Android/Sdk/platform-tools
sudo ./adb kill-server
#If this still doesn't work unplug the usb cable and connect again.
#And repeat the last step Kill the ADB server.
What the F... ! :)
Note : I have seen it on android 8.1 on a One+5t...
Even we do all of above, it is necessary to make something on your android device .. in addition to go in dev options menu (usb debug) (don't hesitate to reset "cancel authorization" or something like this (I am in french version ;) )
If some people meet the same problem than me, maybe it could be usefull for you too :
Don't forget to authorize devices in your phone (each time of usb connect on the android device if you don't select always box). Beside, you can suppress the old authorized devices on your phone and start with proper parameter to authorize clearly your pc on your android device
When you connect the android device, a pop up or notification ask to authorize a mac address or equivalent to the device : authorize it if you want to authorize connection between your linux pc and your android device.
It is necessary to obtain autorisation on your android device when you use connect the usb cable (if you don't accept all the time but if it is the first time this box is going to appear on your devices) if you don't do it, adb devices show unauthorized even all rights are good (666, UDEV etc)
Note : thank you for your precious help.
A last thing, sorry for my english
I'm facing this issue while run flutter app from android studio 4.1, i did remove usb cable and plug into second usb port and its working :),
I'm writing this if someone face same issue then they can get help.
Same issue on Fedora 32, to fix this try this:
adb kill-server
adb start-server
For me and possibly many others the issue is to do with access rights to devices on the machine. Now that this is well documented in the android documentation, I think the best solution is here
On Debian based Systems you can run lsusb or dmesg to get vendor id if your vendor does not exist on the given list
I have face the same problem and i have resolved this by
Adding the path of your_android_sdk_path to the environment variable like
sudo export $PATH:/your_android_sdk_path/platform-tools/adb
its your wish how you want to add this to your account or system wide by editing these file ~/.bashrc file or ~/.profile
or
/etc/profile, /etc/bash.bashrc, or /etc/environment if u want to add to system wide access.
and then create the link of that in bin
sudo ln -s /your_android_sdk_path/platform-tools/adb /bin/adb
if you have used adb devices or any command then first kill the server like
adb kill-server
then start the server like
adb start-server
adb devices
now you can see your devices are listed properly without an issue
As the error message said, it is a permission insufficient problem. In my experience, it only happened on my Linux machine, and works well on MacOS and Windows. Launching your Android Studio with root permission could avoid this problem.
$sudo /your_android_studio_path/bin/studio.sh
In my situation:
cd /etc/udev/rules.d/
sudo chmod a+r ./*.rules #the name of your rules files.
Then,I can use adb without this error.
if accepted answer not worked for you then just simple follow steps:
Just open your android studio terminal:-
adb kill-server
adb start-server
it worked for me.
Without running Linux
sudo apt-get install adb. Don't forget to enable USB debugging.
Ref: https://developer.android.com/studio/run/device

How to solve ADB device unauthorized in Android ADB host device?

When I'm using a rooted Android device as ADB host to send adb command "adb devices" to Samsung S4, I received device unauthorized error message. However when I tried adb to Samsung Galaxy Nexus, it is working fine. Can anyone advise how to solve my Samsung S4 problem?
=========================================
# adb devices
List of devices attached
4d00f9169907301b unauthorized
=========================================
Edit:
Found that this problem only happened to Android 4.2.2 and above. The following link explained that Google has implemented some new security features for using adb.
http://nelenkov.blogspot.com/2013/02/secure-usb-debugging-in-android-422.html
Appreciate if anyone can help on this.
Get the public key from the client phone (adb host)
cat /data/.android/adbkey.pub
copy the above public key to the target phone's /data/misc/adb/adb_keys location. (you may need to stop the adb daemon first with stop adbd)
cat /data/misc/adb/adb_keys
verify both cat outputs match.
try restarting adb daemon on target start adbd or just reboot them.
If you are having problems reading or writing to ADB KEYS in above steps, try setting environment variable ADB_KEYS_PATH with a temporary path (eg: /data/local/tmp). Refer to that link it goes into more details
"On the host, the user public/private key pair is automatically generated,
if it does not exist, when the adb daemon starts and is stored in
$HOME/.android/adb_key(.pub) or in $ANDROID_SDK_HOME on windows. If needed,
the ADB_KEYS_PATH env variable may be set to a :-separated (; under
Windows) list of private keys, e.g. company-wide or vendor keys.
On the device, vendors public keys are installed at build time in
/adb_keys. User-installed keys are stored in /data/misc/adb/adb_keys"
Check and uncheck the USB Debugging option in the device.
If that doesn't work unplug and plug in the USB a couple of times.
At some point, the device should show a message box to ask you to authorize the computer. Click yes and then the device will be authorized.
If anyone has similar issue of having a phone with a cracked screen and has a need to access adb:
Root your phone (mine was already rooted, so I was blessed at least with that).
If you forgot to enable developers mode and your adb isn't running, then do the following:
Reboot your phone into recovery.
Connect the phone with a cable.
Open terminal.
If you type adb devices you should see the device in the list.
If so, type:
adb shell mount /system
abd shell
echo "persist.service.adb.enable=1" >> default.prop
echo "persist.service.debuggable=1" >> default.prop
echo "persist.sys.usb.config=mtp,adb" >> default.prop
echo "persist.service.adb.enable=1" >> /system/build.prop
echo "persist.service.debuggable=1" >> /system/build.prop
echo "persist.sys.usb.config=mtp,adb" >> /system/build.prop
Now if you are going to reboot into your phone android will tell you "oh your adb is working but please tap on this OK button, so we can trust your PC". And obviously if we can't tap on the phone stay in the recovery mode and do the following (assuming you are not in the adb shell mode, if so first type exit):
cd ~/.android
adb push adbkey.pub /data/misc/adb/adb_keys
Hurray, it all should be hunky-dory now! Just reboot the phone and you should be able to access adb when the phone is running:
adb shell reboot
P.S. Was using OS X and Moto X Style that's with the cracked screen.
Have you tried
adb kill-server
adb shell
Sometimes adb gets stuck and first killing adb server and then starting some command forces authorization window to pop-up.
Also please check adb client version on your phone.
THis feature is supported from adb 1.0.31 as far as I remember.
Experience With: ASUS ZENFONE
If at all you have faced Missing Driver for Asus Zenfones
Follow This Link
(http://donandroid.com/how-to-install-adb-interface-drivers-windows-7-xp-vista-623)
I tried with
1) Killing and starting adb server at adb cmd.
2) Switching Usb Debugging on and Off and ...
This is What WORKED with me.
Step 1:Remove Connection with Device and Close Eclipse
Step 2:Navigate to C:/Users/User_name/.android/
Step 3:You Will Find adb_key
Step 4:Just delete it.
Step 5.Connect again and System will ask you Again.
Step 6.Ask Device to remember RSA Key when it Prompts. I think its done.
If you Face The Same Problem after couple of days, just disable and enable USB debugging
For unknown reasons, I only had ~/.android/adbkey, but not ~/.android/adbkey.pub.
I guess that adb was unable to push the public key to the device, and thus the device could never show the authorization dialog.
After killing the adb server, removing the adbkey file and starting adb again, the authorization dialog popped up on the phone.
Try this steps:
unplug device
adb kill-server
adb start-server
plug device
You need to allow Allow USB debugging in your device when popup.
You need to allow Allow USB debugging when the popup shows up when you first connect to the computer!
Delete the folder .android from C:/users/<user name>/.android. It solved the issue for me.
I had to check the box for the debugger on the phone "always allow on this phone". I then did a adb devices and then entered the adb command to clear the adds. It worked fine. Before that, it did not recognize the pm and other commands
For me, the emulator could not have Google Play Services enabled. It could have Google APIs or be x86 or x64 but not google play store.
Try a USB2 port if you're plugged into a USB3 port. At least through the Pixel3 line this makes a difference. Many people have observed the same problem but I'm not sure if anybody knows why. Perhaps there's a way to tell the kernel to not do something USB3-ish on the USB port that the phones can't handle.
I got here because I forgot this workaround, found this page, then remembered to use the other port.
Please follow following steps :
Unplug your phone from system
Go to developer options of the Cellphone and then click on "Allow USB debugging" then please select the radio button prompting "Allow USB debugging when the popup shows up when you first connect to the computer!".....
That's it.. run your command again :
adb devices
You must be prompted in your s4 screen to authorize that computer. You can tell it to remember it. This is for security reasons, occurring in Android 4.4+
I found one solution with Nexus 5, and TWRP installed. Basically format was the only solution I found and I tried all solutions listed here before: ADB Android Device Unauthorized
Ask Google to make backup of your apps. Save all important files you may have on your phone
Please note that I decline all liability in case of failure as what I did was quite risky but worked in my case:
Enable USB debugging in developer option (not sure if it helped as device was unauthorized but still...)
Make sure your phone is connected to computer and you can access storage
Download google img of your nexus: https://developers.google.com/android/nexus/images
unrar your files and places them in a new folder on your computer, name it factory (any name will do).
wipe ALL datas... you will have 0 file in your android accessed from computer.
Then reboot into BOOTLOADER mode... you will have the message "you have no OS installed are you sure you want to reboot ?"
Then execute (double click) the .bat file inside the "factory" folder.
You will see command line detailed installation of the OS. Of course avoid disconnecting cable during this phase...
Phone will take about 5mn to initialize.

Android adb show "Allow USB debugging?" window

I am using Mobogenie software to backup data on my smartphone. When I do it, program invokes "Allow USB debugging?" window on my device, obviously via ADB. The question is - how? In the screenshot below (it is in Russian language)
button which is in red ellipse says: "Show this popup window again" and when I press it, my device shows "Allow USB debugging?" window. But i couldn't find any useful information about how to do the same thing - with ADB (which command should I use) or any other way. Maybe sombody got an idea? Or is there any way to kind of trace commands or find out how this progrom does it?
ADB Secure device authorizations are stored in a whitelist located here: /data/misc/adb/adb_keys
There's no way to remove RSA keys from the whitelist without having root access.
Having said that... If you do not "Allow USB Debugging" when that window pops up (by pressing cancel) or if you do not check the box that says "Always allow from this computer", then the RSA key is not stored in the whitelist. By running adb kill-server and then adb start-server, it forces a new check of the connected computer's RSA key.
My guess is that the button that is circled is there basically just kills and restarts the ADB server to have the popup come back, in case the user did not "Always allow" or if they Cancelled the request.
EDIT: I see that Mobogenie also includes a "one click root" feature... As sketchy as that sounds, if your device is rooted, then Mobogenie could be deleting your computer's stored key from your whitelist. As for this theory, there are multiple methods - one being simply doing a pure delete:
adb start-server
adb shell
cd /data/misc/adb
rm abd_keys
exit
adb kill-server
adb start-server
I also got the same issue in my lenovo mobile. Initially I thought the issue is with my mobile.
But actually the issue is the adb don't have enough permission to read the rsa key to communicate with the device. When we run adb server it'll create a folder named .android(Linux - /home/--username--/.android, Windows - C:/Users/--username--/.android) in the home directory of the current user which contains the adb rsa key files used to communicate between the devices.
When I check the folder is assigned with root permission(I am using Ubuntu 16.04 and I don't know how its assigned). So when I try to run adb start-server it is trying to create .android folder. But the current folder with root access is not allowing this to create the adb keys. That's why its failed.
So I deleted the folder using below command. Use the particular method to delete the folder based on your operating system. Below I mentioned for linux.
sudo rm -rf .android
Then restarted the adb server using below command.
adb start-server
Now It created the .android folder with the current user permission. Once done this I got the Allow USB debugging dialog.
Hope it help someone.

Categories

Resources