Android Make File (Automate)

Android Make File (Automate)
0.0 0


Hey guys, I have a project that I started porting from cocos2d-iPhone, and I have to say I love cocos2d-x! I feel right at home!

Everything is going smoothly in Xcode, however this issue in Android is killing me:

I really need to find a way to automate the process. Each time I add a cpp file (Which I have 114 file in total) I have to edit the make file, in order to test it on android.

Could anyone help me automate this?

I can write bash scripts, but I am not a pro. The best I could do now, is iterate the *.cpp files, and generate “…/Clases/Class1.cpp …/Classes/Class2.cpp” … etc, then copy it into the make file. I would rather use a more convenient method that does not involve openning the make file and editing it manually…


After looking around for a while, there seems to be a feasible solution

Writing a bash script that would iterate the *.cpp file, and generate a file (call it classes_vars for example), and in that file we output ANDROID_CLASSES=“…/Clases/Class1.cpp …/Classes/Class2.cpp”. Finally, just link that file somehow in the make file, and use the $ANDROID_CLASSES variable.

I haven’t written the script yet, and would love to at least hear some thoughts about this?!


one thing you can do by modifying in JNI folder and Genrating a file which points to game classes.

setp 1. put all the .cpp and .h file is Classes folder [without any subfolders] … i know sounds unorganized but it works.
step 2. : download “
step 3 : put it in folder
setp 4 : modify in JNI folder like

search for line :

LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static cocos_extension_static


LOCAL_WHOLE_STATIC_LIBRARIES := cocos_game_common cocos2dx_static cocosdenshion_static cocos_extension_static

add “cocos_game_common”

or if you see structure like this

LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static


LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static

“cocos_game_common” that is name of the module for all the game classes in /Classes folder


at the end of file

add one line like

$(call import-module,CocosDenshion/android) \
$(call import-module,cocos2dx) \
$(call import-module,extensions)


$(call import-module,gameFolder/Classes) \
$(call import-module,CocosDenshion/android) \
$(call import-module,cocos2dx) \
$(call import-module,extensions)

gameFolder is the name of the folder in your COCOS2DX root in which your cocos2dx project in generated.

AFTER modifing the make file just put one line in , you must add it to first line of



whenever you run ./ all the classes in /Classes folder will be complied , limitation of my script is .cpp and .h should not be in subfolders.

Whenever i need to test for android i do this way only. :slight_smile: peace .


:smiley: Perfect!

This should be a sticky thread or something, so everyone can benefit from it.

Cheers! :smiley:


:slight_smile: thank you

If you want to get rid of placing resources and classes one by one into /Classes and /Resources , as i am using Xcode then
I have one more modification to automatically build /Classes and /Resources folder out of the subfolders in them.

step 1. put in folder.
step 2. add one more line in … this line should be at first.


step 3. I forget to tell please perform chmod a+x on both files.

if your folders or files contains spaces then these both scripts will not work … ++

thank you :slight_smile:


Wait, am I missing something, I can’t find the “genrateMakeFile” attached? :stuck_out_tongue:


ohh sorry

now check


OK, it’s working :smiley:

I have a few small notes:

  1. since I am lazy, I copy/pasted your code, and there was a typo that we missed :stuck_out_tongue:



  1. In the file , we should modify the old LOCAL_SRC_FILES, and make it only point to classes outside the Classes folder, to avoid duplicate inclusion:

LOCAL_SRC_FILES := hellocpp/main.cpp

Thanks a lot Nitesh :smiley:


:smiley: …. 2nd point i forget to mention :slight_smile: …. i am glad to share something … good luck for your game:)