标签:
在java编译那些事通过提到ant编译Java工程,如今扩大到用它来构建Android目,事实上道理是相通的。变化的仅仅是使用的形式。ant构建相比IDE的优点是多个子项目使用自己定义jar包时,ant能够更好的完毕自己主动化构建。一个命令就搞定整个项目的编译而不用手工的导出jar包然后再将其放到指定文件夹。
这就是高效的构建工具所标榜的。
先来说说ant在Linux下的安装(那篇文章写的太过简单,事实上也是非常easy的,别看mannul中写的那么复杂)。
[linc@localhost ant]$ cp ~/Downloads/apache-ant-1.9.4-bin.zip . [linc@localhost ant]$ unzip apache-ant-1.9.4-bin.zip [linc@localhost ant]$ cd apache-ant-1.9.4 [linc@localhost apache-ant-1.9.4]$ ls bin fetch.xml INSTALL lib manual README etc get-m2.xml KEYS LICENSE NOTICE WHATSNEW
15 export ANT_HOME=/home/linc/dev/ant/apache-ant-1.9.4 16 export JAVA_HOME=/usr/java/jdk1.6.0_25 17 export PATH=${PATH}:${ANT_HOME}/bin为了让改动马上生效。运行一下 source ~/.bashrc
[linc@localhost apache-ant-1.9.4]$ ant Buildfile: build.xml does not exist! Build failed
[linc@localhost BallGame]$ android -h update project Usage: android [global options] update project [action options] Global options: -h --help : Help on a specific command. -v --verbose : Verbose mode, shows errors, warnings and all messages. --clear-cache: Clear the SDK Manager repository manifest cache. -s --silent : Silent mode, shows errors only. Action "update project": Updates an Android project (must already have an AndroidManifest.xml). Options: -l --library : Directory of an Android library to add, relative to this project‘s directory. -p --path : The project‘s directory. [required] -n --name : Project name. -t --target : Target ID to set for the project. -s --subprojects: Also updates any projects in sub-folders, such as test projects.
除了參数-p路径是必须的,其它參数都能够不带。
可是建议名称-n要加上。否则会默认以Activity名称来命名。-t能够不做改动,项目的Target Id事实上就是指Android API的版本号,我们能够查看项目的project.properties,以此为基准。例如以下:
[linc@localhost BallGame]$ tail project.properties ... # Project target. target=android-4
[linc@localhost BallGame]$ android update project -p . Updated local.properties No project name specified, using Activity name ‘MainActivity‘. If you wish to change it, edit the first line of build.xml. Added file ./build.xml Added file ./proguard-project.txt
也能够指定更全的參数:
[linc@localhost BallGame]$ android update project -p . -n BallGame -t android-4 Updated project.properties Updated local.properties Updated file ./build.xml Updated file ./proguard-project.txt至此。build.xml在我们不动一枪的情况下搞定了。
接下来说说复杂的项目ant建。
版权声明:本文博客原创文章。博客,未经同意,不得转载。
Android高效的应用程序开发工具集1---ant构建一个简单的Android工程
标签:
原文地址:http://www.cnblogs.com/mengfanrong/p/4653517.html