1

I installed android-sdk in /opt/android-sdk folder modified /etc/environment file as below

ANDROID_SDK=/opt/android-sdk
PATH=...:$ANDROID_SDK/platform-tools:$ANDROID_SDK/tools

logged out and login again. If I type adb or android in terminal it shows command not found.

:~$ echo $ANDROID_SDK
/opt/android-sdk

:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$JAVA_HOME/bin:$ANDROID_SDK/platform-tools:$ANDROID_SDK/tools

I think I am doing something wrong. Please correct me.

anunaki
  • 111

2 Answers2

4

In /etc/environment variable expansion is not performed. You cannot define a variable here and then reference it with $. Your path literally includes "$ANDROID_SDK" which is not expanded into /opt/android-sdk

If you want to define your path in /etc/environment then use the full paths

    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/android-sdk/platform-tools:/opt/android-sdk/tools

(and your full JAVA_HOME path which I don't see in your question.)

Rather than defining your path system-wide, you may want to define it locally (generally preferred).

The local version of /etc/environment is ~/.pam_environment. This has a slightly different syntax. To set the path here, reference the current path and append your additions like this:

PATH DEFAULT=${PATH}:/opt/android-sdk/platform-tools:/opt/android-sdk/tools

(and your JAVA_HOME path too after another colon)

You also can use ~/.profile or in ~/.bashrc - in these files you can use the normal shell syntax with $ expansion like you did before.

After you define it, you then need to source the file by doing source .profile or whichever file you used, or by logging out and back in. (The exception is .bashrc which is sourced every time you start an interactive shell, so opening a new terminal would be enough)

Zanna
  • 70,465
0

Well to solve this issue , I recommend you to provide the environmental parameters in the profile. That is kindly add those ANDROID_SDK and PATH parameters at the bottom of the file /etc/profile. Then logout and login and just see , it will work.

SAGAR Nair
  • 1,385