1, first according to COCOS2D-X environment configuration requirements (ant, etc.) installed, and then in the Android directory proj.android new BUILD.bat, the script is as follows:
@echo offecho prepare to start echo set path set root_path= "F:\test" set project_path= "%root_path %\proj.android "set resources_path="%root_path%\resources "set cocos2dx_path="%ROOT_PATH%\cocos2d\ Cocos\platform\android\java "Set today=%date:~0,4%%date:~5,2%%date:~8,2%set finishdir=" F:\test2\% today% "echo Delete Android Project Assets folder echo #################################################### #if exist %project_path%\assets ( del /q /f %project_ Path%\assets dir %project_path%\assets /ad /b /s > del.txt for /f %%i in (del.txt) do rd %%i /s /q) echo Delete complete echo #################################################### #echo Copy the latest resource resources to the Android Project Assets folder echo #################################################### #ping -n 3 127.0.0.1>nulcall xcopy %resources_path% %project_path%\assets /e /y echo Copy Complete echo # ################################################### #echo ndk compiling so files echo ############################# ####################### #ping -n 3 127.0.0.1>nulpushd %project_path%call ndk-build -j4 NDK_DEBUG=0echo Compile Complete popdecho ######################################################## ########################################################### #echo Update Android Project echo ################### ################################################################################################# ping -n 3 127.0.0.1>nulpushd %COCOS2DX_PATH% call android update project --name testgame -t 1 -p %project_path%popdecho Update Complete echo ###### ############################################## #echo Delete bin folder echo ################################### ############### # #ping -n 3 127.0.0.1>nulif exist %PROJECT_PATH%\bin ( del /q /f %project_path%\bin) echo Delete complete echo ############################## ###################### #pushd %PROJECT_PATH%echo Generate release version apkecho ###################### ############################## #ping -n 3 127.0.0.1>nulcall ant release popdecho generate release complete echo #################################################### #echo Copy apk to the specified directory echo #################################################### #if not exist % finishdir% ( md %finishdir%) copy "%PROJECT_PATH%\bin\ testgame-release.apk " %finishdir%echo #################################################### #echo Execution complete!!! pause
2, set the signature information, open ant.properties add the following:
Key.store=e:/cocos/test.keystore#keystore password Key.store.password=123456#alias name key.alias=androiddebugkey#alias password key.alias.password=123456
Cocos2d-x Learning Notes (Android Automated Packaging bat script)