mac 下命令行编译eclipse 工程

来源:互联网 发布:景甜面相分析知乎 编辑:程序博客网 时间:2024/05/21 17:46

mac 下命令行编译eclipse 工程

目前大部分 Android 开发者都在用 Android studio 有时候我们需要编译一些 eclipse 工程。最简单的方法是使用命令行工具。有一个工具使用起来比较容易,那就是ant。

打开终端,切换到项目目录并执行以下命令:

$ android update project -p .

就会在目录下生成2个文件,build.xml和local.properties。

(1)编译并签名为debug的.apk需要执行如下命令

 $ ant debug 

编译完成后在 bin/目录下生产 项目名.apk

(2)编译release版本,那就在工程目录新建ant.properties,将下面的配置信息添加到该文件中,注意修改keystore的信息

key.store=/home/android/android/build/test.releasekey
key.alias=android
key.store.password=password
key.alias.password=password

然后执行$ ant release.

如果在执行命令时出现
-bash: android: command not found
编辑~/.bash_profile文件 在文件中增加下面两行,保存后关闭,然后执行
source ~/.bash_profile

export ANDROID_TOOL=/Users/zhaoyan/Development/sdk/tools
export PATH=PATH:ANDROID_TOOL

如果执行 android update project -p . 时出现

Error: The project either has no target set or the target is invalid.
Please provide a –target to the ‘android update’ command.
It seems that there are sub-projects. If you want to update them
please use the –subprojects parameter.

需要执行如下命令

android update project –path . –subprojects –target android-19

0 0