首先打开terminal,然后
1. 启动终端Terminal
2. 进入当前用户的home目录
输入cd ~
3. 创建.bash_profile
输入touch .bash_profile
4. 编辑.bash_profile文件
输入open -e .bash_profile
5.编辑bash_profile文件
下面是我的bash_profile文件:
export PATH=/Users/gaoyoujian/Library/Android/sdk/platform-tools:$PATH
GRADLE_HOME=/Applications/Android\ Studio.app/Contents/gradle/gradle-3.2
export GRADLE_HOME
export PATH=$PATH:$GRADLE_HOME/bin
ANDROID_NDK_ROOT=/Users/gaoyoujian/Library/Android/sdk/ndk-bundle
export PATH=$PATH:$ANDROID_NDK_ROOT
然后输入输入source .bash_profile 也可以重新开启一个terminal #此时重新开启命令行, 当前配置也会生效.
在terminal输入ndk-build,如果出现:
Android NDK: Could not find application project directory ! Android NDK: Please define the NDK_PROJECT_PATH variable to point to it. /Users/xiaohuangrenruanjian/android/android-ndk-r10e/build/core/build-local.mk:143: *** Android NDK: Aborting . Stop.
就表示成功了