因为Intell HAXM占用大量内存,且AVD中运行应用程序的界面比较丑陋,决定更换为Genymotion,其最新版本为2.5.2(2015-07-17发布)。html
先注册一个Genymotion帐号,下载genymotion-2.5.2.exe文件。安装过程很是简单,安装完成后运行Genymotion, 添加一个虚拟设备,而后进入Setting > ADB, 设置Android SDK目录为本地路径,Windows下缺省为C:\Documents and Settings\<user>\AppData\Local\Android\sdk 。android
参照[1]中在Android Studio中安装Genymotion插件的过程:File > Settings > Plugins, 点击Browse Repositories, 而后选择Genymotion, 点击Download以及install, 则Android Studio重启后,能够在Toolbar上看到Genymotion Device Manager快捷键,是一个移动手机的小图标,见下图。
git
同时,还须要经过File > Settings > Other Settings > Genymotion来设置Genymotion的文件夹,就设置为缺省安装路径:C:\Program Files\Genymobile\Genymotion。github
首先在Genymotion中启动虚拟设备,或者在Android Studio Toolbar中,点击Genymotion Device Manager快捷键,而后点击"Start"运行,见下图:shell
则Genymotion虚拟手机界面出现。less
而后在Android Studio中经过Run > Edit Configuration > Android Application > Unnamed > General > Target Device中选择Show choose dialog:ide
开始运行应用程序,而后选择模拟器为Genymotion虚拟设备,则应用程序界面出如今Genymotion虚拟手机中,应用程序界面要比Intell HAXM以及AVD运行的更为漂亮和温馨。测试
与Wireshark不一样,Fiddler一般只抓取HTTP/HTTPS报文,所以在Web开发中逐渐开始普遍使用。那Genymotion中测试时如何与Fiddler配合来抓包呢?ui
可参见[4][5], Windows, 在Genymotion中的配置:spa
(1) Go to Android settings menu
(2) In Wireless & Networks section, select Wi-Fi
(3) Press and hold for 2 seconds WiredSSID network in the list
(4) 选择Modify network:
(5) Check Show advanced options
(6) Select Manual for Proxy settings menu entry
(7) Enter the proxy address: the Fiddler-running PC's IPAddress and Port 8888
注意这里填的PC的IP地址是指运行Fiddler的PC上"Ethernet adapter VirtualBox Host-Only Network"的IPv4地址,在DOS窗口中执行ipconfig/all命令可看到,该地址一般是192.168.238.1,见下图:
(8) 按Save button保存设置。
在Fiddler中的配置:
点击Tools menu > Fiddler Options > Connections,选中the Allow remote computers to connect。
注意Fiddler缺省监听端口是8888。若是这里修改成其余值,例如9000,那么Genymotion中Proxy设置的端口值也须要相应地修改成9000:
而后重启Fiddler。
利用Fiddler捕获iPhone手机与Mac系统发出的HTTP/HTTPS可参见小坦克的博文[6][7]。
若是在Fiddler中显示请求的响应时间,可参见[8],摘取其内容以下:
在Tool bar上面找到Rules->CustomRules, 此时须要下载fiddlersyntaxsetup.exe文件,下载完成安装后,在class Handlers{ 里面添加如下代码:
function BeginRequestTime(oS: Session) { if (oS.Timers != null) { return oS.Timers.ClientBeginRequest.ToString(); } return String.Empty; } public static BindUIColumn("Time Taken") function CalcTimingCol(oS: Session) { var sResult = String.Empty; if ((oS.Timers.ServerDoneResponse > oS.Timers.ClientDoneRequest)) { sResult = (oS.Timers.ServerDoneResponse - oS.Timers.ClientDoneRequest).ToString(); } return sResult; }
保存退出就能够了。
[1] Genymotion Download, https://www.genymotion.com/#!/download
[2] Genymotion Release Notes, https://www.genymotion.com/#!/release-notes
[3] Genymotion 2.0 Emulators with Google Play support, https://github.com/codepath/android_guides/wiki/Genymotion-2.0-Emulators-with-Google-Play-support
[4] Genymotion FAQ, https://cloud.genymotion.com/page/faq/#android-proxy
[5] How to setup Fiddler and Genymotion? http://stackoverflow.com/questions/21554235/how-to-setup-fiddler-and-genymotion
[6] Fiddler (四) 实现手机的抓包, http://www.360doc.com/content/14/1126/11/9200790_428168701.shtml
[7] Fiddler (五) Mac下使用Fiddler, http://www.cnblogs.com/TankXiao/archive/2013/05/22/3027971.html
[8] Fiddler显示响应时间, 2015-02-25, http://blog.csdn.net/lglgsy456/article/details/43939291