Remote Debugging Android Devices

//在电脑上远程调试安卓设备

Technical Writer at Google
Meggin is a Tech Writer

Remote debug live content on an Android device from your Windows, Mac, or Linux computer.//远程实时调试安卓设备的内容。

TL;DR

  • Set up your Android device for remote debugging, and discover it from your development machine.
  • Inspect and debug live content on your Android device from your development machine.
  • Screencast content from your Android device into DevTools.

Requirements

To begin remote debugging, you need:

  • Chrome 32 or later installed on your development machine.//电脑上安卓版本号32或者更高的Chrome浏览器。
  • USB drivers installed on your development machine, if you're using Windows. (Ensure Device Manager reports the USB driver correctly)//电脑上安装了安卓设备对应的usb 驱动。
  • A USB cable to connect your Android device to your development machine.//用usb线缆连接安卓设备和电脑。
  • Android 4.0 or later.//安卓版本4.0或者更高。
  • Chrome for Android installed on your Android device.//安卓设备上安装Chrome浏览器。

Enable USB debugging on your Android device

On your Android device, open up Settings, find the Developer options section, and enable USB debugging. If you're running Android 4.2 or later and you can't find Developer options you may need to enable it.//开启安卓设备的开发者选项。

Connect and discover your Android device

On your development machine, open Chrome. You should be logged in to one of your user profiles. Remote debugging does not work in incognito or guest mode.//按下F12键进入开发者工具界面,然后点击三个点图案的菜单-->More tools-->Inspect devices。

Open DevTools and select More tools > Inspect devices.

From here you can see the status of all connected remote devices. You don't have any devices connected right now, so your dialog should look similar to the following screenshot. Make sure thatDiscover USB devices is enabled.//确保勾选了Discover USB devices。

Connect your Android device to your development machine using a USB cable. You should connect your Android device directly to your development machine, not through any intermediate hubs.

If this is your first time connecting this Android device to this development machine, you should see an unknown device that is pending authorization on your Inspect Devices dialog.

If this is the case, then you need to open the Allow USB debugging prompt on your Android device and grant the permissions.

Tip: If you have encounter any issues during the discovery process, you can start the process anew by going back to Developer options and tapping Revoke USB debugging authorizations.

After allowing USB debugging, you should see your device in the Inspect Devices dialog.

Debug content on Android device from development machine

From the Inspect Devices dialog, select your device from the menu on the left.

From here you can see a variety of information about your connected Andoid device:

  • At the top you can see the model name of your Android device followed by its serial number (for example, Nexus 5 #08ae8c2700f43a61).
  • If one or more Chrome tabs are open, then you'll see a Chrome heading followed by the version number of Chrome that's running (for example, Chrome (49.0.2623.105)). If no Chrome tabs are open, you won't see a Chrome heading.
  • Underneath the Chrome heading, each open tab gets its own heading. You can interact with that tab from this section.
  • If there are any running apps using WebView, you'll see a heading for each app.

To open a new Chrome tab, enter a URL in the textfield under the Chrome heading and then clickOpen. A new tab automatically opens and loads the specified URL.

To reload, focus, or close an open tab, click the more options icon next to the inspect button.

To open up DevTools on your development machine and inspect or debug the live content on your Android device, click the Inspect button next to the tab that you want to investigate. A new instance of DevTools opens up on your development machine.

Note: The version of Chrome on your Android device determines the version of DevTools on your development machine used during remote debugging. So, the DevTools window on your development machine may look different than what you're used to.

When you hover over or select an element in the Elements panel, that element is highlighted on your Android device.

You can also tap on your Android device screen to select an element. First, click on the select element () button in DevTools, and then tap on your Android device screen. The element is selected in the Elements panel of DevTools. Note that the select element button is automatically disabled after the first touch, so you need to re-enable it every time that you want to use this feature.

Screencast from Android device to development machine

Enable the toggle screencast button () to view a screencast of the content on your Android device from within your DevTools window.

Screencasts only display page content. Transparent portions of the screencast represent device interfaces, such as the Chrome omnibox, the Android status bar, or the Android keyboard.

Note: Screencasts continuously capture frames, so you should disable your screencast if your test is sensitive to frame rates.

You can interact with the screencast in multiple ways:

  • Clicks are translated into taps, firing proper touch events on the device.
  • Keystrokes on your computer are sent to the device.
  • To simulate a pinch gesture, hold Shift while dragging.
  • To scroll, use your trackpad or mouse wheel, or fling with your mouse pointer.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License, and code samples are licensed under the Apache 2.0 License. For details, see our Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

上次更新日期:十一月 16, 2016

Remote Debugging Android Devices的更多相关文章

  1. Android WebView remote debugging

    /***************************************************************************** * Android WebView rem ...

  2. Android/iOS Remote debugging

    简单介绍 使用下面方法可以定位webview中的元素,无法定位view中的元素. 原文地址:http://mp.weixin.qq.com/s/y_UfdgjT_pkKgYivJmqt7Q webvi ...

  3. 通过Chrome浏览器进行android调试/Remote Debugging on Android with Chrome

    The way your web content behaves on mobile can be dramatically different from the desktop experience ...

  4. 安卓手机移动端Web开发调试之Chrome远程调试(Remote Debugging)

    一.让安卓打debug模式的apk包 二.将电脑中的chrome升级到最新版本,在chrome浏览器地址栏中输入chrome://inspect/#devices: 在智能手机还未普及时,移动设备的调 ...

  5. 在chrome 总调试cordova出现Detached from the target. Remote debugging has been terminated with reason: Connection lost. Please re-attach to the new target

    在chrome 总调试cordova出现如下错误: "Detached from the target. Remote debugging has been terminated with ...

  6. iOS remote debug & Android remote debug & Chrome & APP

    iOS remote debug & Android remote debug & Chrome & APP iOS remote debugging 如何在 iOS 真机上调 ...

  7. ADT eclipse打开时出现Error: Error parsing C:\Users\admin*\.android\devices.xml

    Error: Error parsing C:\Users\admin*\.android\devices.xml  在ADT eclipse打开项目的时候出现此提示,但是又不影响使用. 原因:之前安 ...

  8. 转:Remote debugging with Visual Studio 2010

    Original URL http://www.codeproject.com/Articles/146838/Remote-debugging-with-Visual-Studio-2010 you ...

  9. Remote Debugging (1)

    The client/server design of the Java debugger allows you to launch a Java program from computer on y ...

随机推荐

  1. TF-IDF 学习

    参考资料, 阮一峰的博客  http://www.ruanyifeng.com/blog/2013/03/tf-idf.html 非常感谢他, 能用如此通俗易懂的文字来阐述概念 TF -- Term ...

  2. dtrace 网站

    Oracle SQL Tuning and CBO Internals: Based Optimizer with CBO Internals and SQL Tuning Optimization ...

  3. [IOS笔记] - 动画animation

    //移动 - (IBAction)translation:(id)sender { CABasicAnimation *traslation = [CABasicAnimation animation ...

  4. Windows系统文件详解【大全】

    这是网络上转载的一篇文章,找不到原创的出处了--详细的介绍了WINDOWS系统文件的用途,我想各位保存一份以后说不定会有用吧,呵呵..这里按A到Z为大家分好类了,查询的话可以按键盘的Ctrl+F进行搜 ...

  5. 【matlab】:matlab中不断的出现计算过程怎么办

    这个问题是会常常性出的.就是matlab中不断的出现计算. 关于这个问题,我们须要考虑的是自己是不是写错了,通常会出现以下两种可能的错误 1,关于计算的函数没有写分号 :这样的是致命问题,假设函数不写 ...

  6. Hibernate调试——定位查询源头

    本文是我在importNew翻译的文章,首发在importNew,这里会定期更新链接. 为什么有时Hibernate会在程序某一部分生成一条指定sql查询?这个问题让人非常难立马理解.当处理不是我们本 ...

  7. Go语言阅读小笔记,来自知呼达达关于unsafe.Pointer的分享.

    第一式 - 获得Slice和String的内存数据 func stringPointer(s string) unsafe.Pointer { p := (*reflect.StringHeader) ...

  8. JD笔试试题(凭记忆写的+人生感悟 try finally )

    京东笔试:技术篇(一套卷.包含測试.算法,研发) 一:填空题(4分 * 15) 15 个 涉及的面很广的选择题,可是比較側重基础.包含数据结构的.c++类的,操作系统的,计算机网络的. 二:编程题(2 ...

  9. pycharm5.0 激活方式

    Pycharm5注册方式   0x1 ,安装 0x2 , 调整时间到2038年. 0x3 ,申请30天试用 0x4, 退出pycharm 0x5, 时间调整回来. ##注册方法2### 注册方法:   ...

  10. 【转载】聊一聊C#的Equals()和GetHashCode()方法

    首先先谈一下Equals()这个方法: Equals()方法,来自于Object,是我们经常需要重写的方法.此方法的默认实现大概是这样的: public virtual bool Equals(obj ...