zhilevan zhilevan - 6 months ago 14
Bash Question

ANDROID_HOME not applied

I try to set

ANDROID_HOME
in bash, I use
CentOs 7
.
First, try to
export
with

export ANDROID_HOME=/home/zhilevan/Android/Sdk


Then

export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools


and w hen I type
$ android
it added correctly.

Problem is: when I close terminal and then type
android
faced with
bash: android: command not found...


In another effort, in last step I type
source .bashrc
but the result is the same "after closing the terminal android :command not found".

where is the problem,why it not work?

Answer

It does not work because when you open a new terminal, the exports no longer exist in the new shell. You need to add them to the ~/.bashrc file which is loaded when opening a new terminal.

Add these two exports in ~/.bashrc:

export ANDROID_HOME=/home/zhilevan/Android/Sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

You can run the following command to add them from terminal:

echo '
export ANDROID_HOME=/home/zhilevan/Android/Sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
' >> ~/.bashrc

Then source the ~/.bashrc (or open a new terminal)

source ~/.bashrc