如何在连接到远程系统的设备上部署和执行应用程序? [英] How can I deploy and execute an application on a device connected to a remote system?

查看:273
本文介绍了如何在连接到远程系统的设备上部署和执行应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在连接到同一网络中另一台计算机的设备上部署测试应用程序并发出命令。

I have a requirement to deploy a test application and issue commands on a device connected to another machine in the same network.

我通读 http://developer.android.com/tools/help/adb.html#directingcommands 但我找不到答案。

I read through http://developer.android.com/tools/help/adb.html#directingcommands but I am not able to find the answer.

我尝试使用 adb connect<远程计算机IP> ,但我却无法使用连接错误。

I tried using adb connect <remote machine IP> but I got unable to connect error.

是否可以在以下位置部署应用程序并执行 adb 命令连接到远程系统的设备?

Is there a way to deploy applications and execute adb commands on a device connected to a remote system?

推荐答案

adb < a href = https://stackoverflow.com/tags/adb/info>标签Wiki :


Android调试Bridge(adb)是一种多功能的命令行工具,可让
与仿真器实例或连接的Android驱动的
设备进行通信。它是一个包含三个组件的客户端服务器程序:

Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device. It is a client-server program that includes three components:


  1. 在开发计算机上运行的客户端。您可以通过发出adb命令从Shell调用客户端。其他Android工具(例如ADT插件和DDMS)也会创建adb客户端。

  2. 服务器,该服务器在开发计算机上作为后台进程运行。服务器管理客户端和在模拟器或设备上运行的adb守护程序之间的通信。

  3. 一个守护程序,它在每个模拟器或设备实例上作为后台进程运行。







adb connect 命令用于将本地 adb 服务器 adbd 连接网络连接设备上的守护程序。但是,您想要的是将本地 adb 客户端连接到远程计算机(在另一个系统上运行) adb 服务器 adb 可执行文件的默认行为是连接到 adb 服务器。如果没有找到,它将尝试启动一个。这种方法非常适合在单个系统上完成所有开发的大多数环境。但是在更复杂的环境中,这可能导致启动多个 adb server 实例。并且由于 adbd daemon 仅支持一次连接到单个 adb 服务器-该设备将被一个系统识别,并且在其他任何地方都将丢失。


adb connect command is used to connect the local adb server with the adbd daemon on a network connected device. But what you want is to connect the local adb client to the remote (running on another system) adb server. The default behavior of the adb executable is to connect to the local instance of the adb server. If none found it would try to start one. This approach works great for most environments where all development is being done on a single system. But in more complicated environments it may result in multiple instances of adb server being launched. And because adbd daemon only supports being connected to a single adb server at a time - the device will get recognized by one system and will appear missing everywhere else.

因此,为了使 adb 可靠识别配置较为复杂的设备,您需要告诉 adb 停止猜测,并手动指定 adb 的哪一部分(即 server client )应该在哪个系统上运行。

So in order for adb to reliably recognize devices in those more complicated configurations you need to tell adb to stop guessing and manually specify which part of adb (i.e. server or client) should be running on which system.

首先,请确保您拥有相同的服务器在本地和远程系统上都安装了足够新的 adb 版本(最新的Google官方版本通常效果最好)。而且在任何一个系统上目前都没有运行 adb 个服务器。

First off make sure that you have the same and sufficiently recent version of adb (the latest Google official version usually works the best) installed on both local and remote systems. And that no adb servers are currently running on either system.

然后启动<$ c $的实例使用以下命令,将c> adb服务器放置在远程系统上(您将设备插入到其中):

Then start an instance of the adb server on the remote system (the one which you will be plugging the devices into) with this command:

adb -a -P <PORT_NUMBER> nodaemon server

现在您可以强制 adb 客户通过添加 -H< REMOTE_IP>在本地系统上使用其他(远程)服务器,而不是启动其自己的(本地)实例。 -P< PORT_NUMBER> 到您的 adb 命令:

Now you can force adb client on the local system to use the other (remote) server instead of starting its own (local) instance by adding -H <REMOTE_IP> -P <PORT_NUMBER> to your adb commands:

adb -H <REMOTE_IP> -P <PORT_NUMBER> devices

或者,设置 ANDROID_ADB_SERVER_ADDRESS =< REMOTE_IP> ANDROID_ADB_SERVER_PORT =< PORT_NUMBER> 客户端上的环境变量将使您避免指定< REMOTE_IP> < PORT_NUMBER> ,每个 adb 命令。

Alternatively, setting ANDROID_ADB_SERVER_ADDRESS=<REMOTE_IP> and ANDROID_ADB_SERVER_PORT=<PORT_NUMBER> environment variables on the client side would allow you to avoid having to specify the <REMOTE_IP> and <PORT_NUMBER> for every adb command.

如果省略,则< PORT_NUMBER> 将默认为 5037

And if omitted the <PORT_NUMBER> would default to 5037.

用于 adb 编排的官方内置解决方案不是 SSH的互斥替代方案隧道-它只是解决了另一个更重要的问题。您可以在此基础上添加隧道以增加额外的安全性或帮助解决多站点网络环境中的路由问题。但是仅凭隧道无法解决所有 adb 连接问题。

This official built-in solution for adb orchestration is not a mutually exclusive alternative to the SSH tunneling - it just addresses another more important issue. You can add tunneling on top of this to add extra security or help with routing issues in a multi site network environment. But the tunneling alone will not be able to solve all the adb connectivity problems.

对于虚拟化环境也是如此-在 host guest 系统之间运行多个 adb服务器实例也将导致 adb 连接问题。

Same goes for the virtualized environments - running multiple adb server instances between host and guest systems will also result in the adb connectivity issues.

这篇关于如何在连接到远程系统的设备上部署和执行应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆