Android SDK1.5开发体验

05 May 2009

 

今天在机房尝试了一下Android SDK1.5,下载,安装,修改PATH,和以前一样,不熟悉的话还是去http://developer.android.com/sdk/1.5_r1/index.html上自己看吧。

下面说个小问题,之前版本的SDK,你写个HelloWorld,按照google网站上说的,run的时候,会出现

[2009-05-05 16:18:13 - HelloWorld] ------------------------------
[2009-05-05 16:18:13 - HelloWorld] Android Launch!
[2009-05-05 16:18:13 - HelloWorld] adb is running normally.
[2009-05-05 16:18:13 - HelloWorld] Performing com.jiang.android.HelloWorld activity launch
[2009-05-05 16:18:13 - HelloWorld] Failed to find an AVD compatible with target 'Android 1.1'. Launch aborted.

针对这个问题官方的解释在

http://developer.android.com/guide/developing/eclipse-adt.html#Running

看懂了之后其实很容易,就是在运行模拟器之前必须要自己创建一个AVD(Android Virtual Device,Android虚拟设备),相当于配置你要模拟的目标平台一样,方法如下:

1.打开CMD,输入命令android list targets,查看所有可用的目标平台(如果出现android命令无法找到,是因为你的PATH变量没配置,这就不用我多说了),显示结果为

Available Android targets:

id: 1
    
Name: Android 1.1
    
Type: Platform
    
API level: 2
    
Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P

id: 2
    
Name: Android 1.5
    
Type: Platform
    
API level: 3
    
Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P

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

2.创建一个你想要的AVD,使用如下命令

android create avd --name<your_avd_name>--target<targetID>

例如:andorid create avd --name adt15 --target 2命令,创建了一个名为adt15的2号(Android1.5)平台的AVD。

3.然后会询问是否配置硬件设备,我没有硬件,就没配置,默认是NO,如果你想配置的话,输入yes就行。

4.回到Eclipse里,继续RUN,这是就能搞定了。

PS一下:模拟器编译装载实在是太慢了,一个HelloWorld要用7分钟,才能运行,不过好歹是能运行了,一下是Eclipse里的输出:

[2009-05-05 16:35:26 - HelloWorld] ------------------------------
[2009-05-05 16:35:26 - HelloWorld] Android Launch!
[2009-05-05 16:35:26 - HelloWorld] adb is running normally.
[2009-05-05 16:35:26 - HelloWorld] Performing com.jiang.android.HelloWorld activity launch
[2009-05-05 16:35:26 - HelloWorld] Automatic Target Mode: launching new emulator with compatible AVD 'android15r1'
[2009-05-05 16:35:26 - HelloWorld] Launching a new emulator with Virtual Device 'android15r1'
[2009-05-05 16:35:30 - HelloWorld] New emulator found: emulator-5554
[2009-05-05 16:35:30 - HelloWorld] Waiting for HOME ('android.process.acore') to be launched...
[2009-05-05 16:40:28 - HelloWorld] HOME is up on device 'emulator-5554'
[2009-05-05 16:40:28 - HelloWorld] Uploading HelloWorld.apk onto device 'emulator-5554'
[2009-05-05 16:40:29 - HelloWorld] Installing HelloWorld.apk...
[2009-05-05 16:42:11 - HelloWorld] Success!
[2009-05-05 16:42:11 - HelloWorld] Starting activity com.jiang.android.HelloWorld on device
[2009-05-05 16:42:51 - HelloWorld] ActivityManager: Starting: Intent { comp={com.jiang.android/com.jiang.android.HelloWorld} }

这时你在模拟器里就能看到Helloworld了,注意,一定要耐心等待。



blog comments powered by Disqus