Cocos2d-x 3.6 still sh: cocos: command not found

I created a project using cocos2d-x 3.6 and try to build android version using eclipse, but it shows errors:

**** Build of configuration Release for project MyGame1 ****

python /Users/aronho/Desktop/MyGame1/proj.android/build_native.py -b release all 
sh: cocos: command not found
Please use cocos console instead.

Traceback (most recent call last):
  File "/Users/aronho/Desktop/MyGame1/proj.android/build_native.py", line 43, in <module>
    build(opts.build_mode)
  File "/Users/aronho/Desktop/MyGame1/proj.android/build_native.py", line 28, in build
    raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!")
Exception: Build dynamic library for project [ /Users/aronho/Desktop/MyGame1/proj.android/../ ] fails!

**** Build Finished ****

I saw some solutions before, also some environment variables like ANDROID_SDK_ROOT, NDK_ROOT,… are in .profile, I am quite sure it is not caused by missing environment variables (cocos command is ok in terminal), but the problem still exists (I also add the variables again in eclipse, but the problem is not solved), is there any solution that can solve the problem without editing build_native.py?

Did you use setup.py to setup the cocos with your environment?

Without , setup nothing gonna work , after setup , better restart your pc

And try this on cmd : cocos.py -h

If it’s working or not …

I’m on mac , and everything works just like eat watermelon

Check and tell me what you got

1 Like

setup.py run before, also I checked the .profile and seeems all variables exist…

The error only occurs in eclipse build button, in terminal it is ok (cocos command also works in terminal)

I want to solve the problem in eclipse because I don’t want to edit the code in eclipse and then open the terminal to type the build command

If you want Eclipse C++ build to use build_native.py correctly, within Eclipse, go to Window -> Preferences -> C/C++ -> Build -> Environment

Now, click on Add, and add the following environment variables and their corresponding values according to your work environment:

ANDROID_SDK_ROOT = path-to-android-sdk
ANT_ROOT = path-to-ant-bin
COCOS_CONSOLE_ROOT = path-to-cocos2d-console-bin
NDK_ROOT = path-to-android-ndk
NUMBER_OF_PROCESSORS = number-of-parallel-compiler-threads
PATH = ${PATH}:${ANDROID_SDK_ROOT}:${ANT_ROOT}:${COCOS_CONSOLE_ROOT}
cocos = ${COCOS_CONSOLE_ROOT}/cocos

for me it always says permission denied when i try to use cocos in terminal

Simply change the permission with this

chmod 755 cocos
chmod 755 cocos.py

U can find those in cocos tools folder

And will work

If want more help ask… me

Got the same problem.

This post solve problem: Cocos2d-js setup.py cocos command not found

Here we have missed step:
http://www.cocos2d-x.org/wiki/Linux_Installation_and_Setup
“git submodule update --init”
before “cmake” step.