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.