Android 错误:设备离线

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10680417/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 04:34:54  来源:igfitidea点击:

Error: device offline

androiddebuggingandroid-emulatoradb

提问by program-o-steve

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

模拟器正在运行。但是当我adb shell在 shell 中写入时,我得到:

error:device offline

错误:设备离线

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

这是什么原因?我该如何摆脱它?

回答by German

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.

如果“adb 设备”列出了您的设备,但“离线”可能是您的路径导致旧版本的 adb(例如 1.0.29)与最新的 Android 4 设备存在问题。确保“adb version”返回 1.0.31 或更高版本。从 Android 4.2.2 开始,您必须在您的设备上确认它已连接到受信任的计算机。它将与 adb 版本 1.0.31 及更高版本一起使用。

回答by kdehairy

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

它发生在我身上一次。我刚刚重新启动了设备,这为我解决了问题。

回答by zhangxaochen

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

当我遇到同样的错误时,我只是拔下插头再插上,错误就消失了。

回答by juejiang

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

我重新启动了计算机,同时重新启动了手机。adb 设备返回正常。

回答by Alvaro Gutierrez Perez

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

如果您通过 USB 连接,请拔下并重新插入。

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

如果您通过 WiFi 连接,请禁用并重新启用手机上的 WiFi。

回答by Chris Knight

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

如果您使用的是 Linux 或 Mac,并假设离线设备是“emulator-5554”,则可以运行以下命令:

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:

这告诉我进程 ID 4848 仍在侦听端口 5554。您现在可以使用以下命令终止该进程:

sudo kill -9 4848

and the ghost offline-device is no more!

幽灵离线设备不复存在!

回答by Shiv Buyya

Try to run:

尝试运行:

adb kill-server
adb start-server

Still device offline, please restart device.

设备仍然离线,请重启设备。

回答by mars newing

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.

我两次遇到这种情况。第一次在我的电脑上使用命令“adb kill-server”,然后重新启动了android设备。有效。然而第二次该方法不再起作用。这次我断开并重新连接网络。有效。

回答by Vignesh KM

Method 1 :

方法一:

run this commands in your linux terminal

在您的 linux 终端中运行此命令

sudo adb kill-server
sudo adb devices

run this commands in your CMD

在您的 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.

“adb devices”结果必须显示任何带有 id 的设备。如果您离线而不是 id 意味着您需要在选项卡中授予权限。在android中启用USB调试并首次连接设备后,您将收到一个警告对话框以授予权限。如果您没有收到任何弹出窗口,请单击“开发人员”选项中的“撤销 USB 权限”,然后尝试一次。

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.

更新 adb 以及设备驱动程序。

回答by Ecip

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.

确保你是超级用户.. 而不是 'adb start-server' 做 'sudo adb start-server',输入你的密码(它不会回显),按回车键。然后,'sudo adb devices' 它将显示为在线。