Saturday, January 3, 2009

不用Eclipse,建立Android程序

如果要不用Eclipse 创建一个Android项目,可以参照如下步骤:
1.建立样板文件#####################################
earthfans@mylaptop:~/develop/android-sdk/tools$ ./activitycreator --out HelloAndroid com.android.hello.HelloAndroid
Package: com.android.hello
Output directory: HelloAndroid
Activity name: HelloAndroid
Created directory /home/earthfans/develop/android-sdk/tools/HelloAndroid/src/com/android/hello
Added file HelloAndroid/src/com/android/hello/HelloAndroid.java
Created directory /home/earthfans/develop/android-sdk/tools/HelloAndroid/bin
Created directory /home/earthfans/develop/android-sdk/tools/HelloAndroid/libs
Created directory /home/earthfans/develop/android-sdk/tools/HelloAndroid/res/values
Added file HelloAndroid/res/values/strings.xml
Created directory /home/earthfans/develop/android-sdk/tools/HelloAndroid/res/layout
Added file HelloAndroid/res/layout/main.xml
Added file HelloAndroid/AndroidManifest.xml
Added file HelloAndroid/build.xml

2编译########################################

earthfans@mylaptop:~/develop/android-sdk/tools/HelloAndroid$ ant
Buildfile: build.xml

dirs:
[echo] Creating output directories if needed...
[mkdir] Created dir: /home/earthfans/develop/android-sdk/tools/HelloAndroid/bin/classes

resource-src:
[echo] Generating R.java / Manifest.java from the resources...

aidl:
[echo] Compiling aidl files into Java classes...

compile:
[javac] Compiling 2 source files to /home/earthfans/develop/android-sdk/tools/HelloAndroid/bin/classes

dex:
[echo] Converting compiled files and external libraries into bin/classes.dex...

package-res:

package-res-no-assets:
[echo] Packaging resources...

debug:
[echo] Packaging bin/HelloAndroid-debug.apk, and signing it with a debug key...
[exec] Using keystore: /home/earthfans/.android/debug.keystore

BUILD SUCCESSFUL
Total time: 4 seconds
3 安装到Android模拟器中####################################
earthfans@mylaptop:~/develop/android-sdk/tools$ ./adb -s emulator-5554 install HelloAndroid/bin/HelloAndroid-debug.apk
68 KB/s (4368 bytes in 0.062s)
pkg: /data/local/tmp/HelloAndroid-debug.apk
ps.如果不能确定现在模拟器的编号,可以用下面的命令#######################
earthfans@mylaptop:~/develop/android-sdk/tools$ ./adb devices
List of devices attached
emulator-5554 device
PS2:我用上面官方介绍的方法编译了,但提示是程序已经在模拟器中的提示,不知问题在哪儿,以后水平提高再看看原因。

No comments:

Post a Comment