使用adb连接到Raspberry Pi 3

8

如何连接到运行Android Things的树莓派3,使用adb进行连接?


Android Things: 连接到 Raspberry Pi 3 - Onik
3个回答

9

针对树莓派的Android Things只支持使用以下命令使用adb-over-ip连接adb:

adb connect `<raspberry-pi-ip-address>`

您有多种选项可以找到您的IP地址,具体取决于您的Pi设置:

  • If your Pi is connected to Ethernet and a screen: it should show you its IP address on the Android Things launcher screen.
  • If you have a headless Pi connected to Ethernet: you can directly ping Android.local if you have mDNS/Bonjour support, or see https://learn.pimoroni.com/tutorial/raspberry-pi/finding-your-raspberry-pi for info on how to find your Pi IP address using third-party tools.
  • If you don't have any screen or Ethernet connection, you can connect a USB to TTL serial cable on the UART0 connector (see pinout and type the following command to connect to a WiFi network and get the Pi IP address:

    am startservice -n com.google.wifisetup/.WifiSetupService \
        -a WifiSetupService.Connect \
        -e ssid '<NETWORK_SSID>' -e passphrase '<NETWORK PASSPHRASE>'
    ifconfig
    

虽然它连接以太网时工作正常,但无论如何都无法通过 WiFi 连接。尝试了你提供的第三种方法,在日志中似乎运行良好,但是无法获取任何 IP 地址。有没有其他解决方案? - Riddhiman Adib
@RiddhimanAdib 你是否在口令周围加上了“单引号”? - proppy
我总是在连接wifi时遇到问题,原因通常是它会解析到旧的IP地址,而设备却使用了新的IP地址。我甚至可以通过“ping”和“arp”命令进行测试,但adb无法连接。我仍在寻找更好的方法,因为每天都要花费大约20分钟来进行第一次启动,然后重复使用该IP地址进行下几次启动。 - Fabio

0

从Google Play下载一个终端仿真器(有很多是免费的)。确保您的Android设备已连接到Wi-Fi并获取Wi-Fi IP地址。打开终端程序并键入:

su setprop service.adb.tcp.port 5555 stop adbd start adbd 现在转到您的计算机(假设您正在使用Windows)并在桌面上为“cmd.exe”创建一个快捷方式(不带引号)。

右键单击cmd快捷方式,选择“以管理员身份运行”

更改为android-sdk-windows\tools文件夹

键入:

adb connect ***wifi.ip.address***:5555

(example: adb connect 192.168.0.105:5555)

现在adb应该显示您已连接。

注意:如果您太快地输入连接命令,可能会失败。因此,在您说这不起作用之前,请尝试至少两次间隔五秒钟。


问题是关于Android Things的,因为它没有Google Play。 - Fabio

0

按照以下步骤进行:

它适用于我的 Android 版本 [5.0]

安装 ConnectBot 在您的平板电脑上安装 ConnectBot,这是一个可从 Google Play 下载的 Android 终端模拟器。它允许 SSH 连接到 Raspberry Pi。

配置 Raspberry Pi 您可以通过任何方法连接到 Raspberry Pi 时执行这些更改。 将以下行添加到您的网络配置中:

vi /etc/network/interfaces

允许热插拔usb0 iface usb0 inet dhcp

当您已经连接了所有设备,并且不想重新启动时,只需重启网络:

/etc/init.d/networking restart

连接您的设备

使用微型 USB 电缆将 Android 平板电脑连接到 Raspberry Pi USB 端口。使用标准 USB 电源为 Raspberry Pi 提供电力。您可以使用任何 DC USB 电源。 **启用 Android USB 共享网络 在 Android 平板电脑上启用 USB 共享网络。

*设置 → 连接 → 共享网络和 Wi-Fi 热点 → USB 共享网络** 现在,Raspberry 将自动通过其 USB0 端口获取 IP 地址。Android 平板电脑表现得像 NAT 路由器。当您的平板电脑连接到 Wi-Fi 或移动 3G/4G 网络时,这应该都可以使用。

启动 SSH 登录 Raspberry Pi

在 Android 上启动 ConnectBot 应用

通过 SSH 登录 Raspberry Pi

唯一的问题是您必须知道 Raspberry Pi 的 IP 地址;它似乎是(总是?)192.168.42.159...

网络设置 此部分必须由您自己使用 SSH 和本地网络配置完成。


我相信这个问题特别涉及到Android Things(https://developer.android.com/things/index.html),而不是普通的Android设备。 - mangini
抱歉,我没有读到那个,但是让我来帮助您通过TCP连接ABD。 - Farhan Ansari
截至今天(预览2),树莓派还没有USB功能(除了音频?)。 - Fabio

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接