1.建立一個android項目
參數說明:-k /--package 為命名空間(包名)-a /--name 工程名-p /--path 項目 -t 為目標平台的版本編號
命令:./android create project -k com.android.yunju -a yunju -t 5 -p ~/Download/yunju
列出不同平台的版本編號命令:android list targets
2、已有項目更新
以建立的項目更新ant對已經存在的android工程,可以update下(修改平台的版本),這樣會自動添加build.xml 等ant 的設定檔
命令:./android update project --name yunju -t 5 -p ~/Documents/YunJU/
當然,你要在android sdk tools的目錄下。
3、命令列編譯打包
參考:http://developer.android.com/tools/building/building-cmdline.html
ant 參數如下:debug:帶調試用簽名的構建 release:構建應用程式,產生的apk必須簽名才發行就緒install:安裝調試構建的包到運行著的模擬器或者裝置;reinstalluninstall
在Android專案檔下:ant debug ,會打包出來調試簽名的apk。
4、release打包方式
在ant.properties 檔案中添加
key.store=path/to/my.keystorekey.alias=mykeystorekey.store.password=wodemimakey.alias.password=wodemima
再運行:ant release
-release-sign: [echo] Signing final apk... [signapk] Run cancelled: no changes to input file /Users/rongfzh/Documents/YunJU/bin/yunju-release-unsigned.apk [zipalign] Run cancelled: no changes to input file /Users/rongfzh/Documents/YunJU/bin/yunju-release-unaligned.apk [echo] Release Package: /Users/rongfzh/Documents/YunJU/bin/yunju-release.apk[propertyfile] Updating property file: /Users/rongfzh/Documents/YunJU/bin/build.prop[propertyfile] Updating property file: /Users/rongfzh/Documents/YunJU/bin/build.prop[propertyfile] Updating property file: /Users/rongfzh/Documents/YunJU/bin/build.prop[propertyfile] Updating property file: /Users/rongfzh/Documents/YunJU/bin/build.prop-post-build:release:BUILD SUCCESSFULTotal time: 2 seconds
產生三個apk,其中一個就是簽名好的發布的apk了。
也可以打包完成立即安裝:ant release install