编程william hill官网
直播中

胡秋阳

13年用户 5435经验值
私信 关注

android sdk + eclipse配置好后的helloworld

如果你已经安装好android sdk,eclipse的avd插件也安装好了。就可以开始hello world了。

新建一个android项目,填好项目名,还要选择Build Target(我选的sdk1.6),

application name: HelloWorld

package name: org.dx.hello

(复选框默认勾上)Create Activity: Hello

finish。

出现错误: Failed to find an AVD compatible with target 'Android 1.6'. Launch aborted.

使用sdk tools直接在命令行新建一个虚拟设备

E:mobileandroid-sdk-windowstools>android create avd --name Test --target 3
Android 1.6 is a basic Android platform.
Do you wish to create a custom hardware profile [no]y

SD Card support: Whether the device supports insertion/removal of virtual SD Car
ds.
hw.sdCard [yes]:y

Abstracted LCD density: Must be one of 120, 160 or 240. A value used to roughly
describe the density of the LCD screen for automatic resource/asset selection.
hw.lcd.density [160]:

DPad support: Whether the device has DPad keys
hw.dPad [yes]:

Accelerometer: Whether there is an accelerometer in the device.
hw.accelerometer [yes]:

Maximum horizontal camera pixels
hw.camera.maxHorizontalPixels [640]:

Cache partition size
disk.cachePartition.size [66MB]:

Audio playback support: Whether the device can play audio
hw.audioOutput [yes]:

Track-ball support: Whether there is a trackball on the device.
hw.trackBall [yes]:

Maximum vertical camera pixels
hw.camera.maxVerticalPixels [480]:

Camera support: Whether the device has a camera.
hw.camera [no]:y

Battery support: Whether the device can run on a battery.
hw.battery [yes]:

Touch-screen support: Whether there is a touch screen or not on the device.
hw.touchScreen [yes]:

Audio recording support: Whether the device can record audio
hw.audioInput [yes]:

GPS support: Whether there is a GPS in the device.
hw.gps [yes]:

Cache partition support: Whether we use a /cache partition on the device.
disk.cachePartition [yes]:

Keyboard support: Whether the device has a QWERTY keyboard.
hw.keyboard [yes]:

Max VM application heap size: The maximum heap size a Dalvik application might a
llocate before being killed by the system. Value is in megabytes.
vm.heapSize [16]:

Device ram size: The amount of physical RAM on the device, in megabytes.
hw.ramSize [96]:

GSM modem support: Whether there is a GSM modem in the device.
hw.gsmModem [yes]:

Created AVD 'Test' based on Android 1.6,
with the following hardware config:
hw.sdCard=yes
hw.lcd.density=160
hw.camera=yes

一般回车就可以了,一些需要的特性暂时用不到,也可以先忽略掉。

然后查看列表:

E:mobileandroid-sdk-windowstools>android list
Available Android targets:
id: 1 or "android-2"
     Name: Android 1.1
     Type: Platform
     API level: 2
     Revision: 1
     Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P
id: 2 or "android-3"
     Name: Android 1.5
     Type: Platform
     API level: 3
     Revision: 4
     Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P
id: 3 or "android-4"
     Name: Android 1.6
     Type: Platform
     API level: 4
     Revision: 3
     Skins: HVGA (default), QVGA, WVGA800, WVGA854
id: 4 or "android-5"
     Name: Android 2.0
     Type: Platform
     API level: 5
     Revision: 1
     Skins: HVGA (default), QVGA, WQVGA400, WQVGA432, WVGA800, WVGA854
id: 5 or "android-6"
     Name: Android 2.0.1
     Type: Platform
     API level: 6
     Revision: 1
     Skins: HVGA (default), QVGA, WQVGA400, WQVGA432, WVGA800, WVGA854
id: 6 or "android-7"
     Name: Android 2.1-update1
     Type: Platform
     API level: 7
     Revision: 2
     Skins: HVGA (default), QVGA, WQVGA400, WQVGA432, WVGA800, WVGA854
id: 7 or "android-8"
     Name: Android 2.2
     Type: Platform
     API level: 8
     Revision: 1
     Skins: HVGA (default), QVGA, WQVGA400, WQVGA432, WVGA800, WVGA854
id: 8 or "Google Inc.:Google APIs:8"
     Name: Google APIs
     Type: Add-On
     Vendor: Google Inc.
     Revision: 1
     Description: Android + Google APIs
     Based on Android 2.2 (API level 8)
     Libraries:
      * com.google.android.maps (maps.jar)
          API for Google Maps
     Skins: WVGA854, WQVGA400, HVGA (default), WQVGA432, WVGA800, QVGA
Available Android Virtual Devices:
    Name: Test
    Path: C:Documents and SettingsAdministrator.androidavdTest.avd
  Target: Android 1.6 (API level 4)
    Skin: HVGA

可以看到已经Test设备创建好了。

回到eclipse,如果项目有错误,刷新一下。右键run as android application, 可以看见模拟器了,

改下Hello->res->values->string.xml文件

把hello对应的value改下,再重新运行,oh,成就感来了。

回帖(1)

446975

2013-7-3 16:42:17
建议好好看看android教程,按照上面说的做
举报

更多回帖

发帖
×
20
完善资料,
赚取积分