关于3.5 3.6版本sh: cocos: command not found解决方法

可以用的,谢谢分享,楼主笔误,更正。

try: COCOS_CONSOLE_ROOT
except Exception:
print “COCOS_CONSOLE_ROOT not define. Please define COCOS_CONSOLE_ROOT in your environment!”
sys.exit(1)
command = '%s/cocos compile -p android -s %s -m s' (COCOS_CONSOLE_ROOT, app_android_root, build_mode)

感谢纠正。确实没发现。

按照版主的方法修改 依然无效
eclipse

**** Build of configuration Release for project Healer3.5 ****

python /Users/wyk/Documents/project/Healer/Healer3.5/proj.android/build_native.py -b release all
Please use cocos console instead.

COCOS_CONSOLE_ROOT not define. Please define COCOS_CONSOLE_ROOT in your environment!

**** Build Finished ****

.bash_profile

Add environment variable COCOS_CONSOLE_ROOT for cocos2d-x

export COCOS_CONSOLE_ROOT=/Users/wyk/Documents/develop/cocos2d-x-3.5/tools/cocos2d-console/bin
export PATH=$COCOS_CONSOLE_ROOT:$PATH

Add environment variable COCOS_FRAMEWORKS for cocos2d-x

export COCOS_FRAMEWORKS=/Applications/Cocos/frameworks
export PATH=$COCOS_FRAMEWORKS:$PATH

Add environment variable ANT_ROOT for cocos2d-x

export ANT_ROOT=/Applications/Cocos/tools/ant/bin
export PATH=$ANT_ROOT:$PATH

export ANDROID_SDK_ROOT=/Users/wyk/Documents/develop/Android/adt-bundle-mac/sdk
export PATH=$ANDROID_SDK_ROOT:$PATH
export NDK_ROOT=/Users/wyk/Documents/develop/Android/android-ndk-r8d
export PATH=$NDK_ROOT:$PATH

Add environment variable COCOS_TEMPLATES_ROOT for cocos2d-x

export COCOS_TEMPLATES_ROOT=/Users/wyk/Documents/develop/cocos2d-x-3.5/templates
export PATH=$COCOS_TEMPLATES_ROOT:$PATH

build_native.py

#!/usr/bin/python

build_native.py

Build native codes

Please use cocos console instead

import sys
import os, os.path
import shutil
from optparse import OptionParser

def build(build_mode):

current_dir = os.path.dirname(os.path.realpath(__file__))
cocos_root = os.path.join(current_dir, "../cocos2d")


app_android_root = os.path.join(current_dir, "../")

if build_mode is None:
   build_mode = 'debug'
elif build_mode != 'release':
    build_mode = 'debug'

try: COCOS_CONSOLE_ROOT
except Exception:

print “COCOS_CONSOLE_ROOT not define. Please define COCOS_CONSOLE_ROOT in your environment!”
sys.exit(1)
command = '%s/cocos compile -p android -s %s -m s' (COCOS_CONSOLE_ROOT, app_android_root, build_mode)

command = 'cocos compile -p android -s %s -m s' (app_android_root, build_mode)

if os.system(command) != 0:
    raise Exception("Build dynamic library for project  " + app_android_root + " ] fails!")

-------------- main --------------

if name == ‘main’:

parser = OptionParser()
parser.add_option("-n", "--ndk", dest="ndk_build_param", help='it is not used', action="append")
parser.add_option("-p", "--platform", dest="android_platform", 
help='it is not used')
parser.add_option("-b", "--build", dest="build_mode", 
help='the build mode for java project,debug or release.Get more information,please refer to http://developer.android.com/tools/building/building-cmdline.html')
(opts, args) = parser.parse_args()

print "Please use cocos console instead.\n"

build(opts.build_mode)

3.6 一个鸟样

已经更新了,你再试试看。

现在再试试看。

你直接上传个完整文件不成吗

现在确实可以了,感谢版主。

3.5 3.6里面build_native.py里面有一行是这样的:
command = ‘cocos compile -p android -s %s -m s' (app_android_root, build_mode)
我把它改成了:
COCOS_CONSOLE_ROOT = os.environ’COCOS_CONSOLE_ROOT’]
command = '%s/cocos compile -p android -s %s -m s' (COCOS_CONSOLE_ROOT, app_android_root, build_mode)

我想問為什么我的項目文件沒錯,項目總有個叉!用的V3.5版。。。

你导入工程完,有再导入其他包吗?这步做了没?

有啊,导了cocos2d-xV3.5里的…android->…java里的

截图,截图…错误的截图 :7: :7:

好的,要今晚才截到…

找到錯誤了,好像找到解決方法了,我試試

終于可以运行了:904:

不過還是提示
21:49:16 **** Incremental Build of configuration Release for project HelloWorld ****
python /Users/chankengsan/Documents/IOS/HelloWorld/proj.android/build_native.py -b release all
Please use cocos console instead.

COCOS_CONSOLE_ROOT not define. Please define COCOS_CONSOLE_ROOT in your environment!

21:49:18 Build Finished (took 2s.276ms)

我在.bash_profile設了COCOS_CONSOLE_ROOT的

我的报这个错 还有救么?
python E:/girlshow/proj.android/build_native.py -b release all
Process Process-1:
Traceback (most recent call last):
File “D:\Program Files\Python27\lib\multiprocessing\process.py”, line 250, in _bootstrap
sys.stdin = open(os.devnull)
IOError: No such file or directory: ‘nul’
Process Process-2:
Traceback (most recent call last):
File “D:\Program Files\Python27\lib\multiprocessing\process.py”, line 250, in _bootstrap
sys.stdin = open(os.devnull)
IOError: No such file or directory: ‘nul’
Process Process-3:
Traceback (most recent call last):
File “D:\Program Files\Python27\lib\multiprocessing\process.py”, line 250, in _bootstrap
sys.stdin = open(os.devnull)
IOError: No such file or directory: ‘nul’
Running command: compile
Building mode: release
ANT_ROOT not defined. Please define it in your environment
Please use cocos console instead.

Traceback (most recent call last):
File “E:/girlshow/proj.android/build_native.py”, line 43, in
build(opts.build_mode)
File “E:/girlshow/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 E:\girlshow\proj.android…/ ] fails!

00:06:14 Build Finished (took 1s.453ms)

为什么我创建的新项目都没有那个.py的文件。 环境是安装好的,能把他的列子打包成功。 求方法

照着这个方法做了,还是出现这样的问题:
**** Build of configuration Release for project CocosProject ****

python /Users/Zakim/Documents/CocosProjects/CocosProject/proj.android/build_native.py -b release all
Running command: compile
Building mode: release
Updated project.properties
Updated local.properties
Updated file /Users/Zakim/Documents/CocosProjects/CocosProject/proj.android/proguard-project.txt
It seems that there are sub-projects. If you want to update them
please use the --subprojects parameter.
Android platform not specified, searching a default one…
running: ‘/Users/Zakim/Documents/adt-bundle-mac-x86_64-20131030_1/sdk/tools/android update project -t android-19 -p /Users/Zakim/Documents/CocosProjects/CocosProject/proj.android’

building native
NDK build mode: release
NDK_TOOLCHAIN_VERSION: 4.9
Ndk build failed!
Traceback (most recent call last):
Please use cocos console instead.

File “/Users/Zakim/Documents/CocosProjects/CocosProject/proj.android/build_native.py”, line 46, in
build(opts.build_mode)
File “/Users/Zakim/Documents/CocosProjects/CocosProject/proj.android/build_native.py”, line 30, in build
raise Exception(“Build dynamic library for project " + app_android_root + " ] fails!”)
Exception: Build dynamic library for project /Users/Zakim/Documents/CocosProjects/CocosProject/proj.android/…/ ] fails!

**** Build Finished ****

我的build_native.py文件如下:
#!/usr/bin/python

build_native.py

Build native codes

Please use cocos console instead

import sys
import os, os.path
import shutil
from optparse import OptionParser

def build(build_mode):

current_dir = os.path.dirname(os.path.realpath(__file__))
cocos_root = os.path.join(current_dir, "../cocos2d")

app_android_root = os.path.join(current_dir, "../")
    
if build_mode is None:
    build_mode = 'debug'
elif build_mode != 'release':
    build_mode = 'debug'

COCOS_CONSOLE_ROOT = os.environ'COCOS_CONSOLE_ROOT']
command = '%s/cocos compile -p android -s %s -m %s' % (COCOS_CONSOLE_ROOT, app_android_root, build_mode)

if os.system(command) != 0:
    raise Exception("Build dynamic library for project  " + app_android_root + " ] fails!")

-------------- main --------------

if name == ‘main’:

parser = OptionParser()
parser.add_option("-n", "--ndk", dest="ndk_build_param", help='it is not used', action="append")
parser.add_option("-p", "--platform", dest="android_platform", 
help='it is not used')
parser.add_option("-b", "--build", dest="build_mode", 
help='the build mode for java project,debug or release.Get more information,please refer to http://developer.android.com/tools/building/building-cmdline.html')
(opts, args) = parser.parse_args()

print "Please use cocos console instead.\n"


build(opts.build_mode)

请教各位大神呀~求帮忙呀~是在自己解不了!