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