Ant自動化打多渠道包,Android批量打包提速

來源:互聯網
上載者:User

標籤:ant   渠道包   打包   

 Eclipse用起來雖然方便,但是編譯打包android項目還是比較慢,尤其將應用打包發布到各個渠道時,用Eclipse手動打包各種渠道包就有點不切實際了,這時候我們用到Ant幫我們自動編譯打包了。

在eclipse中引入ant請參考  http://www.cnblogs.com/tt_mc/p/3891546.html ,下面是本人ant打包時遇到的一些問題。

---------------------可愛的分割線------------------------------

一、按照上面步驟自己實現了下,在此過程中也遇到了很多問題。

1、配置環境變數android 和 ant,這裡不詳做解釋。

2、如果你的項目有第三方資源套件,則先切換到資源項目的路徑將其轉換為ant可以編譯的。

  執行命令:android update lib-project -p ./

3、切換到主專案的根目錄。

  執行命令 android list target ,可以擷取android編譯的版本。它的id值就是-t參數後面的值。

  D:\project3\MiniTools>android update project -n MiniTools -t 7 -p ./ --subprojects

   -n : 項目名稱,-t 編譯的版本, -p 項目路徑,--subprojects 指存在第三方資源項目的引用。

4、簽名檔案

   

1、不簽名    1.1、android update lib-project -p ./ //將第三方庫檔案編譯成ant可以識別的    1.2、android update project -n test -t 7 -p ./ --subprojects  --在主專案中執行        1.3、ant release  --生產未簽名的apk.2、簽名,完成1的步驟,接著配置下面    2.1、配置keystore        #keystore的路徑,必須使用正斜杠          key.store= "E:/wp_android_sample/me.key"         keystore的密碼          key.store.password=*****        #alias名          key.alias=me        #alias密碼          key.alias.password=******         #渠道市場列表          market_channels=91,360,wandoujia,baidu          #版本號碼          version=1.2.1     2.2、添加渠道打包代碼到build.xml    2.3、執行ant deploy就可以產生簽名的各個渠道包

 

5、在CMD命令視窗輸入 ant release 執行,在項目的bin目錄下生產apk檔案。6、多渠道包就按照上面的方法去做就可以,在複製多渠道包指令碼到build.xml時,放到condition節點下方(之前我放到了最後,打包時有錯誤,之後包指令碼向簽名的位置放了就可以了)。 二、遇到的錯誤及解決方案  1、錯誤null returned 1  
BUILD FAILEDD:\Android\sdk\tools\ant\build.xml:601: The following error occurred while executing this line:D:\Android\sdk\tools\ant\build.xml:653: The following error occurred while executing this line:D:\Android\sdk\tools\ant\build.xml:698: null returned: 1

   解決方案:

  1、在sdk/tools/ant/build.xml檔案中找到aapt.ignore.assets,將它的值改為crunch。

  2、在自己項目的根目錄下build.xml檔案中加入:<property name="aapt.ignore.assets" value="!.svn:!.git:\x3Cdir\x3E_*:.*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~:crunch" />  這樣子就只對自己的項目生效!為什麼會有\x3Cdir\x3E這個東西,其實就是<dir>,不過ant build.xml中不允許使用‘<‘字元,所以要轉義一下。

 

 

參考

http://my.oschina.net/bigtiger/blog/201924

http://bbs.csdn.net/topics/380199724

 

 http://www.cnblogs.com/qianxudetianxia/archive/2012/07/04/2573687.html

 

Android批量打包提速 - 1分鐘900個市場不是夢

Ant自動化打多渠道包,Android批量打包提速

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.