因爲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