原帖位址:http://blog.mcuol.com/User/weishuangbo/article/13320_1.htm
1.下載下傳android sdk
下載下傳位址如下:
http://dl.google.com/android/android-sdk-windows-1.5_r2.zip
http://dl.google.com/android/android-sdk-linux_x86-1.5_r2.zip
2.下載下傳eclipse 3.4.2
按官方文檔說,android sdk 可以運作在eclipse 3.3以上的IDE中,ubuntu源中的eclipse版本過低,建議使用eclipse 3.4.2,其下載下傳位址為:
http://download.actuatechina.com/eclipse/eclipse/downloads/drops/R-3.4.2-200902111700/eclipse-SDK-3.4.2-linux-gtk.tar.gz
3.安裝eclipse 3.4.2
先将eclipse解壓:
$tar xzvf eclipse-SDK-3.4.2-linux-gtk.tar.gz
将解壓出的eclipse檔案夾移動到目标目錄中去,在這裡我設定的安裝目标為:/usr/local下。
$sudo mv eclipse /usr/local/
4.安裝android sdk
解壓android sdk包:
$unzip android-sdk-linux_x86-1.5_r2.zip
移動到目标目錄:<在這裡我将解壓出的sdk檔案夾目錄改成了android-sdk>
$mv android-sdk-linux_x86-1.5_r2 android-sdk
$sudo mv android-sdk /usr/local/
5.配置環境變量:
修改~/.bashrc檔案,加入android sdk與eclipse的環境變量。
$vi ~/.bashrc
在檔案的最後加入
export PATH=/usr/local/android-sdk/tools:/usr/local/eclipse:$PATH
儲存并退出vi
使配置資訊生效
$source ~/.bashrc
6.android avd配置資訊的生成
android avd的建立格式為:android create avd -n your-avd-name -t your-targets
其中:-n的參數為我們要建立的avd的名字;-t的參數為Available Android targets的id,我們可以使用指令:android list查尋其具體資訊。
$android list
Available Android targets:
id: 1
Name: Android 1.1
Type: Platform
API level: 2
Skins: HVGA-P, HVGA (default), QVGA-P, HVGA-L, QVGA-L
id: 2
Name: Android 1.5
Type: Platform
API level: 3
Skins: HVGA-P, HVGA (default), QVGA-P, HVGA-L, QVGA-L
id: 3
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Description: Android + Google APIs
Based on Android 1.5 (API level 3)
Libraries:
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: QVGA-P, HVGA-L, HVGA (default), QVGA-L, HVGA-P
Available Android Virtual Devices:
下面我們就以建立一個android 1.5的avd為例:
$android create avd -n android-sdk-15 -t 2
Android 1.5 is a basic Android platform.
Do you wish to create a custom hardware profile [no]yes
Device ram size: The amount of physical RAM on the device, in megabytes.
hw.ramSize [96]:128
Touch-screen support: Whether there is a touch screen or not on the device.
hw.touchScreen [yes]:yes
Track-ball support: Whether there is a trackball on the device.
hw.trackBall [yes]:yes
Keyboard support: Whether the device has a QWERTY keyboard.
hw.keyboard [yes]:yes
DPad support: Whether the device has DPad keys
hw.dPad [yes]:yes
GSM modem support: Whether there is a GSM modem in the device.
hw.gsmModem [yes]:yes
Camera support: Whether the device has a camera.
hw.camera [no]:
Camera support: Whether the device has a camera.
hw.camera [no]:yes
Maximum horizontal camera pixels
hw.camera.maxHorizontalPixels [640]:854
Maximum vertical camera pixels
hw.camera.maxVerticalPixels [480]:480
GPS support: Whether there is a GPS in the device.
hw.gps [yes]:yes
Battery support: Whether the device can run on a battery.
hw.battery [yes]:yes
Accelerometer: Whether there is an accelerometer in the device.
hw.accelerometer [yes]:yes
Audio recording support: Whether the device can record audio
hw.audioInput [yes]:yes
Audio playback support: Whether the device can play audio
hw.audioOutput [yes]:yes
SD Card support: Whether the device supports insertion/removal of virtual SD Cards.
hw.sdCard [yes]:yes
Cache partition support: Whether we use a /cache partition on the device.
disk.cachePartition [yes]:yes
Cache partition size
disk.cachePartition.size [66MB]:100MB
Created AVD ''android-sdk-15'' based on Android 1.5
這樣我們就建立了一個基于1.5的avd,上面的具體意思我想大家都能看懂,就不多說了。下在我們就可以測試一下android emulator了:
$emulator @android-sdk-15 -show-kernel
這樣就可以啟動android emulator了:
加入參數-show-kernel是為了在終端上列印android kernel的資訊。
下面我們配置eclipse,使之支援android sdk:
打開Eclipse,Help->Software Updates->Available Software,點選
Add site,輸入
http://dl-ssl.google.com/android/eclipse/
然後安裝。完成後就可以開始在eclipse上建立android應用程式了。