36

The emulator is running. But when I write adb shell in my shell I get:

error:device offline

What is the reason for this? How do I get rid of it?

Brian
  • 6,910
  • 8
  • 44
  • 82
program-o-steve
  • 2,630
  • 15
  • 48
  • 67

16 Answers16

35

If "adb devices" lists your device but as "offline" chances are your path leads to an old version of adb (eg 1.0.29) which has problems with latest Android 4 devices. Make sure "adb version" returns 1.0.31 or greater. Starting with Android 4.2.2, you must confirm on your device that it is being attached to a trusted computer. It will work with adb version 1.0.31 and above.

German
  • 10,263
  • 4
  • 40
  • 56
  • 3
    +1 Thanks! Good hint. I forget to update my Android SDK _again_. I thought the first update fetched all new stuff. But it didn't. So after second and third update run it worked. – Strubbl Aug 12 '13 at 22:37
15

It happened to me once. I just rebooted the device, and this solved the problem for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
kdehairy
  • 2,630
  • 22
  • 27
11

When I got that same error, I just unplugged and plugged in it and the error disappeared.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
5

Try to run:

adb kill-server
adb start-server

Still device offline, please restart device.

Shiv Buyya
  • 3,770
  • 2
  • 30
  • 25
3

I restarted my computer, and at the same time I rebooted the phone. The adb devices returns fine.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
juejiang
  • 323
  • 4
  • 15
3

Method 1 :

run this commands in your linux terminal

sudo adb kill-server
sudo adb devices

run this commands in your CMD

adb kill-server
adb devices

"adb devices" result must show any device with id. If instead of id you are getting off-line means you need to give permission in your tab. Once you enable USB Debugging in android and connect the device for the first time you will get an alert dialog for giving permission. If you are not getting any pop-up then click on Revoke USB Permission in Developer option the try once.

Method 2:

Change the device connected mode from Media to Camera, sometimes this helped me.

Method 3 :

Update the adb as well as device drivers.

Vignesh KM
  • 1,979
  • 1
  • 18
  • 24
  • I tried many things including reinstalling Android Studio. That's the only one which helped: "Revoke USB Permissions" in Developer Settings -> Plug my device -> Give permission in an alert dialog again -> Done. – Sergey Molchanovsky Jan 21 '21 at 07:47
3

If you are connecting through USB, unplug and plug it in again.

If you are connecting over WiFi, disable and re-enable WiFi on the phone.

Alvaro Gutierrez Perez
  • 3,669
  • 1
  • 16
  • 24
1

If you are on Linux or Mac, and assuming the offline device is 'emulator-5554', you can run the following:

netstat -tulpn|grep 5554

Which yields the following output:

tcp        0      0 127.0.0.1:5554          0.0.0.0:*               LISTEN      4848/emulator64-x86
tcp        0      0 127.0.0.1:5555          0.0.0.0:*               LISTEN      4848/emulator64-x86

This tells me that the process id 4848 is still listening on port 5554. You can now kill that process with:

sudo kill -9 4848

and the ghost offline-device is no more!

Chris Knight
  • 24,333
  • 24
  • 88
  • 134
0

Make sure you're superuser.. Instead of 'adb start-server' do 'sudo adb start-server', enter your password (it will not echo), press enter. Then, 'sudo adb devices' and it will show as online.

Ecip
  • 1
0

I came with this condition twice.The first time I used the command "adb kill-server" in my PC, and restarted the android device. It worked. However the second time the method didn't work any more.This time I disconnected and reconnected the network. It worked.

0

This happened to me running Ubuntu 19.04 and Android 9. I fixed this by turning off developer options then turning it back on. And make sure USB Debugging is allowed in there as well.

retodaredevil
  • 1,261
  • 1
  • 13
  • 20
0

Install this tool (link) and try the following code, do not forget to have the device connected and be attentive to any message.

cd .... platform-tools/

adb kill-server
adb start-server
Juandeyby
  • 19
  • 2
0

I went to my phone settings>>Developer options>>Debugging and turned on this option: "Allow ADB debugging in charge only mode" then this problem solved for me. hope to solve for you too.

0

for me, it was by enabling USB Debugging in developer option:

screenshot
just run adb install apk path after and it will works

javad bat
  • 4,236
  • 6
  • 26
  • 44
0

In my case

adb kill-server
adb connect [ip_address_of_device]
Farman Ameer
  • 1,234
  • 2
  • 16
  • 22
0

try following solutions

  1. make sure USD debugging & WIFI debugging is enabled in develop options
  2. make sure PC & mobile both connected with same WIFI if still doesn't work disconnect & reconnect the mobile and run the command again
Dinesh
  • 835
  • 2
  • 17
  • 37