天天看點

Ant自動化打多管道包,Android批量打包提速在eclipse中引入ant請參考  http://www.cnblogs.com/tt_mc/p/3891546.html ,下面是本人ant打包時遇到的一些問題。 Android批量打包提速 - 1分鐘900個市場不是夢

 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、簽名檔案

   

Ant自動化打多管道包,Android批量打包提速在eclipse中引入ant請參考  http://www.cnblogs.com/tt_mc/p/3891546.html ,下面是本人ant打包時遇到的一些問題。 Android批量打包提速 - 1分鐘900個市場不是夢
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就可以生成簽名的各個管道包      
Ant自動化打多管道包,Android批量打包提速在eclipse中引入ant請參考  http://www.cnblogs.com/tt_mc/p/3891546.html ,下面是本人ant打包時遇到的一些問題。 Android批量打包提速 - 1分鐘900個市場不是夢

5、在CMD指令視窗輸入 ant release 執行,在項目的bin目錄下生産apk檔案。 6、多管道包就按照上面的方法去做就可以,在複制多管道包腳本到build.xml時,放到condition節點下方(之前我放到了最後,打包時有錯誤,之後包腳本向簽名的位置放了就可以了)。   二、遇到的錯誤及解決方法   1、錯誤null returned 1   

BUILD FAILED
D:\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個市場不是夢