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

本文详细介绍了构建Android应用所需的工具和步骤,包括设置环境、生成项目、编译项目和运行应用。通过使用Android SDK、JDK、Ant和OneEditor等工具,开发者可以顺利地创建、编译并运行自己的Android应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

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.

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值