0

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.

2
  • are you sure you edit ~/.bashrc ? it seems like you are trying to change /etc/bash.bashrc and system says you about it. – L.Integra Feb 25 '18 at 18:51
  • Yes, I tried editing the /etc/bash.bashrc file only. If its not the right one, where can I find the actual bashrc file? – Manu Mathur Feb 25 '18 at 18:57
0

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.

7
  • 1
    thanks for making me understand. I found the ~/.bashrc file. However, it would be great if you could also assist me on telling me if the right code that would work with AS. Right now I am pasting this # Add the Android Studio /bin directory to PATH export PATH=$PATH:~/home/tecjunkie/android-studio/bin at the end of my ~/.bashrc file? Is it correct or I need anything else too for setting up PATH correctly? – Manu Mathur Feb 26 '18 at 7:40
  • 5 revisions is not overediting. I have edited this answer 22 times and this answer was edited 50 times. – karel Feb 26 '18 at 15:01
  • I also edit this answer, it was accepted. But again its overwritten.. What's in a name right.. – An0n Feb 26 '18 at 16:30
  • didn't get you both. What are you exactly referring to here? Also, @kalyon - I am still confused. I asked you for the statements to be added in ~./bashrc file. How will your point #4 help me? Are you trying to infer that I should replace my 2 statements with the one you wrote here in point #4? Thanks for all the help. – Manu Mathur Feb 26 '18 at 17:28
  • @mAnN Simply inserting the statements at the end of ~/.bashrc should work, (it has worked for me in the past) however the changes won't take effect until you either you reboot, or run the command in step 4. – Kalyon Feb 27 '18 at 2:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.