使用實機 開發 Android APP 設定教學



這次會在文章中介紹如何用實體機做開發

AndroidApp開發中,可以利用以下其中一個方法進行測試及除錯。

1.           利用模擬器 Android Virtual Device (AVD)
2.           利用實體的Android機器 (如:Google Nexus One)

下面先介紹使用實機做測試開發


在實體的Android儀器開啟「USB偵錯」



選擇設定 (Settings) → 應用程式 (Applications) → 開發 (Development) → USB偵錯 (USB debugging)
Android 4.0: 設定 (Settings) → 開發人員選項 (Developer options) → USB偵錯 (USB debugging)

安裝驅動程式

一般手機的Driver在官網上會有提供
將手機插入電腦後會跳出要安裝Driver 的視窗
(若為X64的系統,記得要進 Disable driver signature enforcement mode)

將你的Android機器以USB跟電腦連結後,會出現找不到Driver的訊息。

開啟控制台內的裝置管理員,找出你的Android機器,右擊後,選擇更新Driver

 
選擇瀏覽電腦上的驅動程式軟體 (即手動安裝驅動程式)

選擇你的Android SDK資料夾,再選usb_driver
(更新: 新的 Google USB Driver package 的位置更改到 <sdk folder>/extras/google/usb_driver
這是在SDK Manager 中可選擇要安裝的選項,記得要勾選)

找到後選擇安裝。
因為在Google Release的版本中絕大部份的手機是沒有包含VID&PIDInf裡面的
所以需要自己做一些修改。
1.  先確定自己的機器的PID and VID是多少。
a.     Device Manager  ->還擇Android Device ->右鍵 Properties
b.     Details-> Hardware Ids ->確認PID & VID
2.  Edit inf file
a.     Edit <sdk folder>/extras/google/usb_driver/android_winusb.inf
b.     加入這兩行記得 VID & PID 要做修改
%SingleAdbInterface% = USB_Install, USB\VID_0BB4&PID_0C92
%CompositeAdbInterface% = USB_Install, USB\VID_0BB4&PID_0C92&MI_01
 


出現安裝完成的訊息。
如果以上的Step都有完成的話,應該會出現安裝完成的訊息
如果出現跟cat檔有關的訊息,是因為我們已經修改過inf file
所以記得!!!  要進入Disable driver signature enforcement mode.

將你的應用程式設定成「可偵錯 (Debuggable)

Eclipse中打開你的應用程式專案(如前文的HelloWorld專案),雙擊AndroidManifest.xml,選擇Application,在Debuggable中選擇true

你亦可以在下面選擇AndroidManifest.xml,在application的標籤內加上「android:debuggable="true"」。

Android機器測試應用程式


Eclipse中的Debug Configuration中記得選擇TargetManual
Apply後會出現你的實體機。
(若要用Virtual Device則選擇下面即可)

當你在Eclipse運行專案後,你將會看到Android Device Chooser,選Choose a running Android device,按OK

Eclipse將會將你的專案安裝到你的Android儀器之中,你可以在你的Android機器中,測試你的應用程式。


References

Alan’s Developement

Developing on a Device | Android Developers

留言