Most of the solutions found on the internet ask you to kill and restart adb server.
adb kill-server
adb start-server
unplug and plug in the mobile phone
uncheck and check the usb debugging option
This does not fix my problem.
Android 4.2.2 has a new security feature where user has to confirm the RSA signature of the computer before it is allowed to connect to the phone. Old version of ADB does not support this feature and will always show your device as offline.
Solution:-
1. Check your adb version and where your adb command points to, on my case, there is an older version of adb at /usr/bin.
adb version
Android Debug Bridge version 1.0.29
type -a adb
/usr/bin/adb
2. Delete the old adb and fastboot. Ubuntu's apt-get installed the outdated version.
cd /usr/bin
sudo rm fastboot
sudo rm adb
3. Download ADT/SDK from http://developer.android.com.
4. Update your system PATH and points to the updated adb
gedit .bashrc (ubuntu, replace with any other text editor you like)
add this to the last line of the file
export PATH=$PATH:...../adt-bundle-linux-x86_64-20130522/sdk/platform-tools (please replace it with the path to the sdk you downloaded)
5. Check your version again
type -a adb
.../adt-bundle-linux-x86_64-20130522/sdk/platform-tools/adb
adb version
Android Debug Bridge version 1.0.31
6. Plug in your phone and enjoy!