cocos2d-x使用ant打包

 

 

1. 下載apache-ant-1.9.3,而後添加環境變量ANT_HOME = D:\dev_envir\apache-ant-1.9.3(你本身的ant根目錄),再在path中添加路徑:%ANT_HOME%\bin;%ANT_HOME%\lib;html

 

2. 配置cocos2dx環境(略過),此處用的cocos2d-x3.x版本java

 

3. 建立項目android

cocos new TestAnt -l cpp -p org.fuxiao.TestAnt -d ./apache

這樣就在當前目錄下建立好了TestAnt項目。ui

 

4. 更新項目this

1)進入proj.android目錄,運行命令android update project -t 3 -p ./更新項目,生成project.properties文件。spa

其中-p是項目路徑,-t是Android target ID,這裏id=3對應的是Android-10,運行命令android list targets便可看到target列表。debug

2)當前項目更新了,還要更新引用庫。進入當前項目的cocos2d/cocos/platform/android/java運行android update project -t 3 -p ./orm

注意兩個地方的target id要同樣。xml

 

5. 編譯項目

執行編譯腳本build_native.py等待項目編譯完成,生成.so庫文件。

 

6. Ant打包

進入proj.android目錄,執行ant debug打出debug版本的包,執行ant release打出release包。想要生成帶簽名的release包,須要在ant.properties文件中填寫你的簽名信息。

key.store=D:/camelliaKey.keystore     #簽名文件路徑

key.store.password=******

key.alias=******                                  

key.alias.password=******  

 

若是打包時出現以下錯誤:

BUILD FAILED
D:\dev_envir\sdk\tools\ant\build.xml:892: The following error occurred while exe
cuting this line:
D:\dev_envir\sdk\tools\ant\build.xml:894: The following error occurred while exe
cuting this line:
D:\dev_envir\sdk\tools\ant\build.xml:906: The following error occurred while exe
cuting this line:
D:\dev_envir\sdk\tools\ant\build.xml:284: null returned: 2

是由於重複引用庫的問題。

1.刪除src/org/cocos2dx目錄下的lib。

2.或者將文件project.properties中對應庫的引用去掉。即去掉android.library.reference.1=../cocos2d/cocos/platform/android/java

 

7. 多渠道批量打包

當咱們的項目要上線不少平臺時,須要打幾十上百個渠道包,而這些渠道包的區別僅僅是他們的渠道號不一樣(方便運營商付費統計)。這時咱們就須要本身寫一個build.xml文件,實現批量打包。(有空時,將會在後面的博客中寫出) ====》》》傳送門:http://www.cnblogs.com/songcf/p/4040412.html

相關文章
相關標籤/搜索