Chinaunix首页 | 论坛 | 博客
  • 博客访问: 470874
  • 博文数量: 120
  • 博客积分: 3052
  • 博客等级: 中校
  • 技术积分: 1755
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-01 09:43
文章分类

全部博文(120)

文章存档

2011年(20)

2010年(3)

2009年(52)

2008年(45)

我的朋友

分类: 嵌入式

2009-10-01 17:22:22

在网上逛,就看到了 Ophone,接着就看到了 android,这个东东居然是由 google 开发的。更引起了我的兴趣。
再看到这个东东是手机上跑的操作系统,而且是 linux+java,正合我几年前的设想,又是用在嵌入式方面,我决定看看这个东东。
正好我用 gentoo, eix -s 了一下,就找到了android-sdk, emerge 之。
一切顺利,只是中间安了一个 ant, 我不是很喜欢,因为我一直用 make 的。先看看再说。
------------------------------------------------------------------
看一本电子书,叫《android: a programmer's guid》,写得是入门的东东,正好适合我看。
网上也有很多教程,只是绝大多数都是讲如何用 eclipse 进行开发的。
eclipse 是个好东东啊,确实是个好东东,这个似乎是公认的,我也不想否认,只是,只是,我不喜欢,我还是喜欢 unix 下各样东西分开来作自己的事情,这样我可以随意地控制它们,想如何自动化就如何自动化。
好在我正看的这本书上有讲如何不用 eclipse 来开发,我喜欢。
-------------------------------------------------------------------
书上讲到,hello world 要用到一个叫 ActivityCreator.py 的脚本,我上 tools 目录里找了下,没有。。。。。。。
find 之,仍然没有发现。
google 之,找到的消息说是在 1.6 这个版本里,用一个叫 android 的程序 replace 了 ActivityCreator,晕。
于是运行 android 看看出什么再说。

不巧的是,给的提示竟然是
basename 不正确的参数
basename --help for ......
这是什么呀?
下面还有提示,说是 VM 找不到。
我就想,怎么回事呢? VM? 莫非是安装的 ant 找不到 java 的 VM ?
打 ant, 给出的错误提示是一样的。
于是 which java
居然在 /usr/bin 下找到了一个符号链接。我晕。
由于 jdk 是我自己手动安装的,这个自然是不对的。 mv java java-old
再运行 android 正常了。可是还是不会用,因为这和书里的是不一样的。怎么办呢?
-------------------------------------------------------------------
android 的程序是在 emulator 上跑的,于是就 emulator 之,看看有什么启示没有,
给出错误提示,说是
emulator: ERROR: You did not provide the name of an Android Virtual Device
with the '-avd ' option. Read -help-avd for more information.

于是 emulator -help-avd
给出

use '-avd ' to start the emulator program with a given Android
  Virtual Device (a.k.a. AVD), where must correspond to the name
  of one of the existing AVDs available on your host machine.

See -help-virtual-device to learn how to create/list/manage AVDs.

  As a special convenience, using '@' is equivalent to using
  '-avd '.
这个正是我想找的,于是接着 emulator -help-virtual-device 给出
An Android Virtual Device (AVD) models a single virtual
  device running the Android platform that has, at least, its own
  kernel, system image and data partition.

  Only one emulator process can run a given AVD at a time, but
  you can create several AVDs and run them concurrently.

  You can invoke a given AVD at startup using either '-avd '
  or '@', both forms being equivalent. For example, to launch
  the AVD named 'foo', type:

      emulator @foo

  The 'android' helper tool can be used to manage virtual devices.
  For example:

    android create avd -n -t 1  # creates a new virtual device.
    android list avd                   # list all virtual devices available.

  Try 'android --help' for more commands.

  Each AVD really corresponds to a content directory which stores
  persistent and writable disk images as well as configuration files.
  Each AVD must be created against an existing SDK platform or add-on.
  For more information on this topic, see -help-sdk-images.

  SPECIAL NOTE: in the case where you are *not* using the emulator
  with the Android SDK, but with the Android build system, you will
  need to define the ANDROID_PRODUCT_OUT variable in your environment.
  See -help-build-images for the details.
这样就差不多了,先试试看。
-------------------------------------------------------------------
还行,不错
android create avd -n hello -t 1
emulator @hello
就可以启动了
只是启动有些慢,我还以为程序死了呢。试了下一些基本功能,我的天啊,这手机也太厉害了吧。。。。有钱了我也买一个,呵呵。
-------------------------------------------------------------------
上面的方法建立的 avd 在 ~/.android 目录下,可是只是一个 virtrul device, 不是用来写程序的。
仔细看了看 android -h 的输出,原来是用 android create project 来建立项目。这个命令还是需要好多参数的,我做测试就用
android create project -k cn.cublog.drunkedcat -n hello2 -a test1 -t 3 -p test1
这几个还都是必须的参数的,
-k 是 package
-n 是项目名称,这个可选
-a 是 activity 的名字
-t 是 target id, 这个不知道是干什么用的
-p 是项目放的位置,找个地方放就是了
如何写程序和生成可用的模块呢?后面再接着学。
阅读(2019) | 评论(1) | 转发(0) |
0

上一篇:firefox plugins

下一篇:android -- hello world

给主人留下些什么吧!~~

chinaunix网友2010-05-27 16:22:34

刘哥,你也研究这个啊?