TransWikia.com

Setting PATH variable for Android Studio Correctly

Ask Ubuntu Asked by Manu Mathur on August 2, 2020

I recently installed Android Studio on my Ubuntu 16.04 LTS. Now, I have two queries:

  1. Is it necessary to set up the PATH variable? If yes, what would be the right approach to do that. I researched different links on this forum like setting-environment-variables-for-android-studio and found that we need to edit ~/.bashrc file found at /etc/ folder, but none helped.

Here is the location of studio.sh file on my system:

/home/tecjunkie/android-studio/bin

I also copied these two commands at the end of ~/.bashrc file:

# Add the Android Studio /bin directory to PATH
export PATH=$PATH:~/android-studio/bin

Source link for above command – setting up Android development on Ubuntu (Check pointer #5)

However, I am still unsure if this is the right way to setup PATH variable on a permanently basis?

Also, whenever I tried saving the ~/.bashrc file, I got an error saying:

Could not save the file "/etc/bash.bashrc". You do not have the 
permission necessary to save the file. Please check that you typed the 
location correctly and try again.

Now, how to setup PATH variable permanently to avoid typing ./studio.sh command everytime?

P.S.

  1. I have tried different links, yet not able to figure out a working solution to setup PATH variables.
  2. I am able to run Android studio from Nautilus and even via terminal (the standard way).

Also, if the experts here need any more detail, please let me know so that I can add it to my question.

EDIT:

Right now I tried creating a Blank activity on AS just to check if AS is opening or not on Linux OS and on the first instance, I faced Gradle sync issue.
Here is the screenshot listing the errors I am getting:

gradle error on MyApplication project

When I tried the same task on Windows OS, the sync operation completed in just 52seconds.

How to get rid of this gradle sync issue on Linux OS because until the sync gets successful, design editor will not be available for use on Linux.

Would request the experts here to assist on this issue as well.

One Answer

Sorry for over-editing this answer, but I think I should include a better explanation.

  1. You do not need to set up the PATH if you do not want to, however you will have to type out the path of the executable every time.

  2. ~/.bashrc should be in your home folder at /home/tecjunkie/.bashrc (~ is a shortcut referring to your home folder). It is, however, hidden so it won't show up in files. You can show hidden files by pressing Ctrl + h in Nautilus, or from terminal by typing ls -a

  3. It appears you are trying to edit the /etc/bash.bashrc file. This will bring identical results, but is unnecessary since the executable is in your home folder. (see What's the difference between /etc/bash.bashrc and ~/.bashrc? Which one should I use?) Editing that file requires root privileges.

  4. In order for changes to the ~/.bashrc to take effect, you need to run:

    source ~/.bashrc 
    

    (Rebooting should work too)

This is the easiest way to add a location to PATH.

Answered by Kalyon on August 2, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP