初体验Android的两个小不爽

 

今天下午花了点时间来体验Android,本以为5分钟就可以完成的Helloworld,却用了将近1个半小时的时间,实在有些不爽。现在暂时记下一些不爽的地方,希望大家能指出问题在哪里?有什么更好的办法?

前面按照安装文档,下载sdk和eclipse plugin,安装配置安装文档一路顺风。马上新建工程,编写Helloworld代码,启动运行。想着应该大工告成,看的到效果收工了。谁知道问题出来了。

代码如下:

package person.pengjun.hello;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
 @Override     
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
TextView tv = new TextView(this);
tv.setText("过河卒, 每天进步1%");
setContentView(tv);
}
}

 

 

不爽1:HelloWorld需启动两次

在Eclipse的run菜单里面配置了Android Appliaction的运行配置,一切OK,启动工程。一切启动正常,按照文档的说发,我就应该能够看到屏幕中显示出来的“过河卒,每天进步1%”的字样了。而我实践看到的确实手机桌面,不解。在手机菜单里面找了好几遍也没有找到相应的启动选项。(PS:到时里面的API DEMO吸引我看了好久)。没办法,没看到效果。只好回头检查是否有错误。

发现Eclipse里面的启动信息如下:

[2007-11-19 18:10:52 - HelloAndroid] ------------------------------
[2007-11-19 18:10:52 - HelloAndroid] Android Launch!
[2007-11-19 18:10:52 - HelloAndroid] Launching: person.pengjun.hello.HelloAndroid
[2007-11-19 18:10:52 - HelloAndroid] Launching the emulator.

回想doc里面说的,启动会先启动emulator,之后才会启动application。

看到这里,我又Ctrl+F11再启动了一次Android Application,结果挺好。终于出现了,我希望看到的界面。

未命名2

启动信息如下:

[2007-11-19 18:12:30 - HelloAndroid] ------------------------------
[2007-11-19 18:12:30 - HelloAndroid] Android Launch!
[2007-11-19 18:12:31 - HelloAndroid] Launching: person.pengjun.hello.HelloAndroid
[2007-11-19 18:12:31 - HelloAndroid] Pushing HelloAndroid.apk to /data/app on the device
[2007-11-19 18:12:31 - HelloAndroid] Starting activity on device: person.pengjun.hello.HelloAndroid
[2007-11-19 18:12:33 - HelloAndroid] ActivityManager: Starting: Intent { comp={person.pengjun.hello/person.pengjun.hello.HelloAndroid} }

 

虽然这没有浪费我什么时间,但是文档里面居然一个字也没有提。不爽。

 




不爽2:修改居然不会自动更新

看到效果了,心里面也不免小兴奋一把。修改了“过河卒,每天进步1%”为“Android,I love you”以表庆祝。启动运行,问题还是依旧,看到的还就手机桌面,心里面不免暗暗叹息。再次Ctrl+F11,这回出来了。但是出来了的字符让我伤心,居然还是“过河卒,,每天进步1%”,这有点受不了了。尝试关闭程序再次尝试,问题依旧。于是想是不是和Web浏览器的缓存一样,那有记录下来了。于是查找一番,果然让我查到了,在手机桌面的Application里面出现了 我的AndroidApplication,启动依然是“过河卒,每天进步1%”。

没办法只好查文档了,折腾了一会,终于让我查到。

http://code.google.com/android/reference/emulator.html#controlling

里面有这样的记录:

Only the first emulator instance can preserve user data across sessions. It stores the user data in a file — by default, it stores the data in the file ~/.android/userdata.img (on Linux and Mac) or C:/Documents and Settings/<user></user>/Local Settings/Android/userdata.img (on Windows) in your development computer. You can control the storage (and loading) location of the user data file by using the -data option when starting the emulator 。

原来在这里C:/Documents and Settings/<user></user>/Local Settings/Android/userdata.img

去到这里,发现什么也没有。不甘心,查找了一下。原来它在C:/Documents and Settings/<user></user>/Local Settings/Application Data/Android/userdata.img 。找到它,毫不客气删除重运行AndroidApplication,终于见到“Android,I love you”。看来还是那句歌唱的好啊,“想说爱你不容易”。

找到问题经过多次尝试,仍然不会自动随修改更新,心里面很是不爽啊。每次修改只好删除,userdata.img再试,实在麻烦。不过暂时也没有更好的办法,只好如此。由于默认目录太偏,而且会影响所有的Android的运行,所以想了个替代的办法。在Eclipse的run菜单里面配置emulator的启动配置。在工程文件下面建一个data文件夹,把这个user data file 指定到这个位置上面。这样每个Application都配置的话相互直接也就不会影响了。配置如下图,

未命名3

不管配置的好,总之还是那个词,不爽。

上面是我今天初用Android遇到的问题,这可能和我机器的运行环境有关系。不知道大家是否也有遇到,不知道大家是否有更好好的处理办法? 请大家多多指点。


11月20日晨
早上换了台机器,重新解压了个eclipse,版本3.3.再次尝试HelloAndroid,居然上面的问题,一个也没有出现。这可能和系统的环境有关系。因为昨天的那台机器上面东西比较杂,也疏于打理。具体是什么方面的影响还不清楚,不过昨天机器的Eclipse是3.1的版本。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值