1.先使用命令:(touch .bash_profile)如果已存在.bash_profile就可以直接打开
open .bash_profile
安卓环境配置
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home
export CLASSPATH=:$JAVA_HOME/lib/dt.jar:$java_home/lib/tools.jar
export M2_HOME=/Users/david/maven/apache-maven-3.3.9
export PATH=$PATH:$M2_HOME/bin
export ANT_HOME=/Users/david/Documents/zahuopu/ruanjian/software/apache-ant-1.10.1
export PATH=${PATH}:${ANT_HOME}/bin
export ANDROID_HOME=/Users/david/Library/Android/sdk
export ANDROID_TOOLS=$ANDROID_HOME/tools
export ANDROID_PLATFORM_TOOLS=$ANDROID_HOME/platform-tools
PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS
cocos2d环境配置
# Add environment variable COCOS_CONSOLE_ROOT for cocos2d-x
export COCOS_CONSOLE_ROOT=/Users/david/Documents/zahuopu/ruanjian/software/cocos2d-x-3.14.1/tools/cocos2d-console/bin
export PATH=$COCOS_CONSOLE_ROOT:$PATH
# Add environment variable COCOS_X_ROOT for cocos2d-x
export COCOS_X_ROOT=/Users/david/Documents/zahuopu/ruanjian/software
export PATH=$COCOS_X_ROOT:$PATH
# Add environment variable COCOS_TEMPLATES_ROOT for cocos2d-x
export COCOS_TEMPLATES_ROOT=/Users/david/Documents/zahuopu/ruanjian/software/cocos2d-x-3.14.1/templates
export PATH=$COCOS_TEMPLATES_ROOT:$PATH
# Add environment variable ANDROID_SDK_ROOT for cocos2d-x
export ANDROID_SDK_ROOT=/Users/david/Library/Android/sdk
export PATH=$ANDROID_SDK_ROOT:$PATH
export PATH=$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$PATH
#ndk
export NDK_ROOT=/Users/david/Documents/zahuopu/ruanjian/software/android-ndk-r10e
export PATH=$NDK_ROOT:$PATH
#ANT
export ANT_ROOT=/Users/david/Documents/zahuopu/ruanjian/software/apache-ant-1.10.1/bin
export PATH=$ANT_ROOT:$PATH
2.配置完后,保存,执行命令:
source .bash_profile
注意:需要实现下载好配置环境需要的东西,比如ndk,ant,sdk等,而且ndk版本貌似太高打包也会出问题,本人之前用的14的,打包总出错,后来换了10e的,可以正常打包了。
cocos creator安卓环境配置:
ndk:/Users/david/Documents/zahuopu/ruanjian/software/android-ndk-r10e
sdk:/Users/david/Library/Android/sdk
ant:/Users/david/Documents/zahuopu/ruanjian/software/apache-ant-1.10.1/bin