- 打开配置文件
sudo gedit ~/.bashrc
2.在末尾加上
export ANDROID_HOME="$HOME/Android/Sdk"
export ANDROID_NDK="$ANDROID_HOME/ndk-bundle"
export PATH="${PATH}:${ANDROID_HOME}tools:${ANDROID_HOME}platform-tools:$ANDROID_NDK"
在这个文件里面写了PATH=xx,那么将来所有的PATH都成了xx了,所以我们应该在这个文件中写为:
PATH=$PATH:xx
保存
$HOME 为home路径, 可以替换成自己Android/Sdk所在的父目录
ANDROID_HOME 为SDK环境变量
ANDROID_NDK为NDK环境变量
- 更新使生效:
source ~/.bashrc
关闭终端,重新打开验证是否添加成功
echo $ANDROID_HOME
echo $ANDROID_NDK
ndk-build -v
查看路径配置
user@host:~$ echo $ANDROID_HOME
/home/<user>/Android/Sdk
验证NDK配置是否成功
user@host:~$ echo $ANDROID_NDK
/home/<user>/Android/Sdk/ndk-bundle
user@host:~$ ndk-build -v
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for x86_64-pc-linux-gnu
参考链接:
https://stackoverflow.com/questions/26256279/how-to-set-android-home-path-in-ubuntu
https://www.jianshu.com/p/b2a5a0ee0919