Compile & Run your .apk in console .命令行下编译调试Android应用

 

Tools you need:

 

for win

1.android-sdk-windows

2.ant for windows

3.jdk for window (1.5 or 1.6 ver)

3.one editor

 

for linux

1.android-sdk-linux

2.ant for linux

3.jdk for linux (1.5 or 1.6 ver)

3.one editor

 

before start our program,to set you PATH env var corretly,like the android-sdk-window/tools,jdk_XXX/bin,JAVA_HOME...

 

1st step. to gennerate the Andorid project.

 

       enter your android-sdk-window dir,use the android program,in windows ,means the android.bat.

 

       android.bat create project /

       --target <target_ID> /

       --name <your_project_name> /

       --path <your_project_path> /

       --activity <your_avtivity_name> /

       --package <your_package_namespace>

 

      e.g c:/android create project --target 4 --name MyHelloWorld --patch d:/Hello --activity HelloWorld

 

      then a project well be create in the path you provided.what have ben create could be see in the console.

 

 

2ed step. to compile your project

 

      now is time to use the Ant,the build.xml file is the makefile for the Ant.

      enter your project dir.

      use cmd Ant,

      e.g D:/Hello>ant debug   

            or    D:/Hello>ant release      the former will compile a debug apk,the latter will compile to a release version that need to  be signed.

 

 

3rd step. to run your .apk

 

      we use the emulator under your android-sdk-XXXX/tools/

      before we run it in a emulator,we need a AVD (Android Virtual Device),you can use the default AVD named AVD ,like this

      D:/Hello>emulator -avd AVD

      I'm not very sure every sdk of different version will have the same defualt AVD,your can see your AVDs use this cammand :  >android list avd    .        it will show all the AVDs that you have.

      To create a new AVD,you can see the emulator help,use CMD:>emulator -help-virtual-device

 

      once startup your AVD,you can use the adb.exe to install your .apk to your emulator.

 

 

你可能感兴趣的:(Compile & Run your .apk in console .命令行下编译调试Android应用)