混合式应用真机调试(Android Studio + Chrome)
如何在chrome上调试混合式APP
https://developers.google.com/web/tools/chrome-devtools/remote-debugging/
Get Started with Remote Debugging Android Devices
Kayce Basques
By Kayce Basques
Technical Writer at Google
Remote debug live content on an Android device from your Windows, Mac, or Linux computer. This tutorial teaches you how to:
这篇教程教你如何在电脑上远程调试Android设备上正在运行的网页
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 onto a DevTools instance on your development machine.
remote debugging illustration
Requirements 要求
Chrome 32 or later installed on your development machine.
USB drivers installed on your development machine, if you're using Windows. Ensure Device Manager reports the correct USB driver.
A USB cable to connect your Android device to your development machine.
Android 4.0 or later.
Chrome for Android installed on your Android device.
Step 1: Discover your Android device
On your Android device, select Settings > Developer Options > Enable USB Debugging. Developer Options is hidden by default on Android 4.2 and later. See Enabling On-Device Developer Options to learn how to enable it.
在Android设备上打开开发者模式
On your development machine, open Chrome. You should be signed in to Chrome with one of your Google accounts. Remote debugging does not work in Incognito Mode or Guest Mode.
打开谷歌浏览器并登陆谷歌账号(需要FQ)
Open DevTools.
打开Chrome开发者工具(打开浏览器菜单-->更多工具-->开发者工具)
In DevTools, click the Main Menu Main Menu then select More tools > Remote devices.
在开发者工具中,点击主菜单,选择更多工具-->远程设备
Opening remote devices drawer
In DevTools, click the Settings tab, if another tab is showing.
Make sure that Discover USB devices is enabled.
Discover USB devices is enabled
Connect your Android device directly to your development machine using a USB cable. Don't use any intermediate USB hubs. If this is your first time connecting your Android device to this development machine, your device shows up under Unknown, with the text Pending Authorization below it.
将你的Android设备直接连接到电脑上,不要使用USB集线器,如果你的Android设备是第一次连接到电脑上,名称应该是未知,需要授权允许连接。
Unknown device, pending authorization
未知设备等待授权
If your device is showing up as Unknown, accept the Allow USB Debugging permission prompt on your Android device. Unknown is replaced with the model name of your Android device. The green circle and the Connected text indicate that you are all set to remotely debug your Android device from your development machine.
Note: If you have any issues during the discovery process, you can restart it by selecting Settings > Developer Options > Revoke USB Debugging Authorizations on your Android device.
Step 2: Debug content on your Android device from your development machine
If you don't already have Chrome open on your Android device, open it now.
在Android手机上打开Chrome
Back in DevTools, click the tab that matches your device's model name. At the top of this page, you see your Android device's model name, followed by its serial number. Below that, you can see the version of Chrome that's running on the device, with the version number in parentheses. Each open Chrome tab gets its own section. You can interact with that tab from this section. If there are any apps using WebView, you see a section for each of those apps, too. The screenshot below does not have any tabs or WebViews open.
回到开发者工具,点击你设备名称的tab页,在顶部可以看到Android设备名称,后面是序列号。下面是Chrome版本号。每打开一个Chrome页面都会生成唯一的路径。你可以通过这个路径与页面进行交互。如果有任何apps使用了WebView,你可以看到对应app的路径。下图截屏中并未打开任何webview(这是原网站上的话,截屏未拷贝过来,下图中我打开了谷歌的首页,可以看到地址)。
Connected remote device
Next to New tab, enter a URL and then click Open. The page opens on a new tab on your Android device.
在新的tab页上,输入网址并打开,这个网址将在Android设备上打开。
Click Inspect next to the URL that you just opened. A new DevTools instance opens. The version of Chrome running on your Android device determines the version of DevTools that opens on your development machine. So, if your Android device is running a very old version of Chrome, the DevTools instance may look very different than what you're used to.
点击网址后的检查按钮,一个新的开发者工具将会打开。你Android设备上的Chrome决定了新弹出的开发者工具的版本号。
More actions: reload, focus, or close a tab
Click More Options More Options next to the tab that you want to reload, focus, or close.
reload, focus, or close a tab
Inspect elements
Go to the Elements panel of your DevTools instance, and hover over an element to highlight it in the viewport of your Android device.
在开发者工具的元素面板,悬停在元素上,Android设备上的该元素会高亮显示。
You can also tap an element on your Android device screen to select it in the Elements panel. Click Select Element Select
Element on your DevTools instance, and then tap the element on your Android device screen. Note that Select Element is disabled after the first touch, so you need to re-enable it every time you want to use this feature.
你也可以在Android设备中点击元素,这样在元素面板就会选中。在开发者工具中点击元素选择(在元素页面tab左侧,一个小鼠标的图标),之后点击Android设备屏幕即可选中该元素。注意第一次选中元素之后,这种模式就会失效,每次选中元素前,都要点击元素选择图标。
Screencast from Android device to development machine
Click Toggle Screencast Toggle Screencast to view the content of your Android device in your DevTools instance.
点击截屏开关可以关闭/打开开发者工具中的Android设备屏幕预览。
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.
Some notes on screencasts:
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.
截屏只显示页面内容,透明的部分表示设备接口,比如Chrome多功能框,Android status bar或Android键盘。
Screencasts negatively affect frame rates. Disable screencasting while measuring scrolls or animations to get a more accurate picture of your page's performance.
截屏会降低框架的效率,所以测试滑动和动画效果时,最好关闭截屏,来获取更精确的页面效果。
If your Android device screen locks, the content of your screencast disappears. Unlock your Android device screen to automatically resume the screencast.
注意
需要在Android上打开debug模式
从 Android 4.4 开始,webkit是支持远程调试的,不过需要将app的debug模式打开,可以使用如下代码:
WebView.setWebContentsDebuggingEnabled(true);
由于大部分 App 的 debug 模式是关闭的,即便是内部 App,比如 QQ/微信,要去找一个开启了debug 模式的版本还是比较麻烦的。因此需要使用借助第三方工具来强制开启任何 App 的 Android webview debug模式,使之可以使用 chrome inspect。而这个工具就是 Xposed 。具体参考:http://imweb.io/topic/56b768ed5c49f9d377ed8ef2
混合式应用真机调试(Android Studio + Chrome)的更多相关文章
- ionic真机调试Android报错 - could not read ok from ADB Server * failed to start daemon * error: cannot connect to daemon
在使用真机调试Android程序时,报错如下: could not read ok from ADB Server * failed to start daemon error: cannot con ...
- 在ubuntu下真机调试android程序出现设备没有访问权限
今天把android的开发环境从windows平台切换到了ubuntu上. java jdk android-adt android-ndk都下好,环境变量都配好之后, 在调试程序的时候,出现设备没有 ...
- mac 下真机调试 android 手机
第一步: 查看usb设备信息 在 终端输入:system_profiler SPUSBDataType 可以查看连接的usb设备的信息 比如我的usb信息如下(部分内容): Spreadtru ...
- Android真机调试 Android.Util.AndroidRuntimeException: You cannot combine custom titles with other title features
参考连接:http://blog.csdn.net/scyatcs/article/details/9003285 Android.Util.AndroidRuntimeException: You ...
- Windows 下 Hbuilder 真机调试(Android,iphone)
概述:主要讲讲自己在使用 HBuilder 真机调试功能时遇到的问题,以及如何解决.Android 相对没有遇到什么大问题,在电脑安装如360手机助手就可以正常使用了,主要问题是在 iphone 上( ...
- 真机调试之android手机+chrome
真机调试之android手机+chrome 虽然chrome上的移动设备模拟器很强大,但是在真机运行的时候,总会遇到一些小问题,这时就需要使用真机调试了. 第一步:准备一台android手机,并在手机 ...
- android studio 开发android app 真机调试
大家都知道开发android app 的时候可以有2种调试方式, 一种是Android Virtual Device(虚拟模拟器) ,另一种就是真机调试. 这里要说的是真机调试的一些安装步骤: 1. ...
- Android studio Error: Modules no specified解决和真机调试
如何配置SDK百度一大堆: 前言:Android Studio很完善,如果SDK配置好,理论上就是 创建项目->创建个APP(名字自己随便起)->打开手机开发者模式运行即可:如果出了问题, ...
- 【Android】Android Studio真机调试的问题统整
真机调试需要注意以下几个问题 [1]手机的USB调试需开启 [2]手机不能是仅充电模式,需要传输数据模式 [3]有些USB线会偷工减料,请拿一条没问题的线,例如买手机时原厂给的配线 [4]在PC端需要 ...
随机推荐
- PREV-42_蓝桥杯_九宫幻方
问题描述 小明最近在教邻居家的小朋友小学奥数,而最近正好讲述到了三阶幻方这个部分,三阶幻方指的是将1~9不重复的填入一个3*3的矩阵当中,使得每一行.每一列和每一条对角线的和都是相同的. 三阶幻方又被 ...
- [转]一图读懂JVM架构解析
每个Java开发人员都知道字节码经由JRE(Java运行时环境)执行.但他们或许不知道JRE其实是由Java虚拟机(JVM)实现,JVM分析字节码,解释并执行它.作为开发人员,了解JVM的架构是非常重 ...
- Spring Boot下Druid连接池+mybatis
目前Spring Boot中默认支持的连接池有dbcp,dbcp2, hikari三种连接池. 引言: 在Spring Boot下默认提供了若干种可用的连接池,Druid来自于阿里系的一个开源连 ...
- [转][CentOS]VI编辑器使用
参考:https://blog.csdn.net/qq_34160679/article/details/79800584 参考:https://www.cnblogs.com/mondol/p/vi ...
- DevOps安装、部署持续集成
1.重启docker服务,开启iptables转发功能 # systemctl start docker # vi /etc/sysctl.conf # sysctl -p [root@localho ...
- centos6.8下l2tp客户端xl2tpd的安装配置
环境: DigitalOcean centos6.8作为l2tp客户端 ros6.43.8作为l2tp服务端 1.安装xl2tp和ppp rpm -ivh http://mirrors.yun-idc ...
- 去掉user agent stylesheet 浏览器默认样式 [ 2.0 版本 ]
今天在写一个网页的时候发现一个问题,我的table的样式很奇怪,也没有设置什么样式,跟其他的页面不一样,打开开发者工具一看,发现有这么点样式: 其中右上角:user agent stylesheet ...
- androidstudio在创建new project时,窗口太大,看不到下面确定按钮的解决方法
点击File-->setting-->Appearance将里面的Override default fonts by(not recommended)打钩去掉. 这个是目前找到唯一办法.
- FileMaker Server连接SQL Server测试
用FM测试了一把扫二维码.效果还不错,简单的设置几下就可以上线,使用Iphone扫二维码进行盘点以及更新照片功能.接下来测试下下ODBC连接. FMS连接SQL Server测试 1. 在FMS服务器 ...
- Linux下使用OTL操作mysql数据库
首先重点推荐介绍otl介绍及用法的文章:http://www.cnblogs.com/fnlingnzb-learner/p/5835560.html 一.编写代码 注:以下代码来自OTL示例,略有改 ...