利用ant在Mac 下自動化打包簽名Android程式

來源:互聯網
上載者:User
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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.