[How To] Fix Android devices not recognised by adb

sd@sd-1:~$adb get-serialno
sd@sd-1:~$ adb shell
error: device offline

If you are one of those frustrated users who cannot get adb to work with your android device, you may be in for a breather.

The issue is probably similar for all operating systems. In Linux and to some extent Mac, this issue may be caused by change in ownership of the folder  .android. This is a hidden folder. You will be able to see it in Nautilus file manager by pressing Ctrl+H or in the command line using the command ll or ls -al.
Diving a little deeper you can confirm whether the .android folder by the current user or some other user. This was the case with my system. Using the command below, you can confirm .
sd@sd-1:~$ll | grep .android
drwxr-x---  2 root     root     4096 Mar  9 00:48 .android/
As you can see from the above list, the folder .android is owned by root and not by the user sd and hence will not be accessed by adb unless you give sudo.
So, to solve the problem, we need to update the ownership the current user. Also, I backed up the old adbkey and adbkey.pub and renamed it as adbkey.bak and adbkey.pub.bak. You may wish to do the same.
sd@sd-1:~$ sudo chown -R sd:sd .android/
sd@sd-1:/home/sd/.android# mv adbkey adbkey.bak
sd@sd-1:/home/sd/.android# mv adbkey.pub adbkey.pub.bak
sd@sd-1:~$ ll .android/
total 24
drwxr-x---   2 sd sd  4096 Mar  9 00:48 ./
drwx------ 108 sd sd 12288 Mar  7 19:31 ../
-rw-------   1 sd sd  1704 Dec 27 13:04 adbkey.bak
-rw-r--r--   1 sd sd   730 Dec 27 13:04 adbkey.pub.bak
 Now unplug the usb cable from the android device and restart the adb server
sd@sd-1:~$ adb kill-server;adb start-server
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
Plug the cable back to the android device and check the adb status. You will see your device is recognized.
sd@sd-1:~$ adb get-state
Windows users can delete the .android folder altogether and try restarting the sever ( I have not tried it. Do not hold me responsible if anything goes wrong.)

Leave a Reply

Scroll to Top