6

I have recently installed Android Studio on Manjaro Linux, but I am experiencing issues every time I have to run the application from the scratch. Namely, in order to start application, I have to be logged in as root, then I have to validate JAVA_HOME environmental variable and finally start the application with ./studio.sh

Here is the full code of that:

[nikodroid@manjaro ~]$ cd /usr/share/applications/android-studio/bin
bash: cd: /usr/share/applications/android-studio/bin: Permission denied
[nikodroid@manjaro ~]$ sudo su
[sudo] password for nikodroid: 
[root@manjaro nikodroid]# cd /usr/share/applications/android-studio/bin
[root@manjaro bin]# ./studio.sh 
which: no java in (/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/vendor_perl:/usr/bin/core_perl)
ERROR: Cannot start Android Studio\nNo JDK found. Please validate either STUDIO_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation.
[root@manjaro bin]# cd /usr/java/
[root@manjaro java]# export JAVA_HOME=/usr/java/jdk1.7.0_21/
[root@manjaro java]# export PATH=$PATH:$JAVA_HOME/bin
[root@manjaro java]# cd /usr/share/applications/android-studio/bin/
[root@manjaro bin]# ./studio.sh

So, obviously this runs only when I am keeping the terminal session, once I exit, the application stops working. My question is, what can I do in order to not do this all every time I want to run the application?

Just to mention, I put the following line

JAVA_HOME=/usr/java/jdk1.7.0_21/

in /etc/environment/ in order to persist this environment variable, but it seems that it didn't work.

Thanks!

nikodroid
  • 171
  • 1
  • 1
  • 4

4 Answers4

9

It really was a permission issue, as I looked and found out that the owner and group were messed up, so what I did is changing the permission/ownership with:

chown -R root:root android-studio

After this, I just changed the dir with:

cd /usr/share/applications/android-studio/bin

and ran

./studio.sh

It loaded the application without any errors.

nikodroid
  • 171
  • 1
  • 1
  • 4
  • 2
    so it appears you are now running android studio as root? please don't do that. – njzk2 Oct 05 '15 at 15:46
  • unless the key point is just that you are in the `root` group but not in the group that was previously set. In which case, `chgrp -R root` is sufficient, but still not optimal. Check which group owns that directory and either add yourself to that group, or change the group to one that represent this better. (`users` for example). You can also create a group just for that (e.g. `android-devs`). Create the group, add yourself to it, the give the ownership of the directory to that group. – njzk2 Oct 05 '15 at 15:52
3

install JRE and JDK with apt

for JRE: sudo apt-get install default-jre for JDK: sudo apt-get install default-jdk

check if all is ok with: java -version

then continue installation Android Studio

1

A similar problem (but in Windows) was solved

adding a system variable JDK_HOME with value c:\Program Files\Java\jdk1.7.0_21\

So, try, adding:

JDK_HOME=/usr/java/jdk1.7.0_21/

to your /etc/environment (as well as keeping JAVA_HOME).


UPDATE:

Try fixing permissions for "/usr/share/applications/android-studio/bin" and "./studio.sh".

Community
  • 1
  • 1
Alejandro Colorado
  • 6,034
  • 2
  • 28
  • 39
  • I've added JDK_HOME under JAVA_HOME in /etc/environment, but I still have to write all the commands in shell, as I wrote in my first post. – nikodroid May 18 '13 at 23:21
  • 1
    Well, it seems there are two different problems. Did JDK_HOME solve the "ERROR: Cannot start Android Studio\nNo JDK found. Please validate either STUDIO_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation."? – Alejandro Colorado May 18 '13 at 23:24
  • After I do following: [root@manjaro java]# export JAVA_HOME=/usr/java/jdk1.7.0_21/ [root@manjaro java]# export PATH=$PATH:$JAVA_HOME/bin I am able to start Android Studio, but only while the current session lasts. When I want to start a new session, I have to type all from the above again. – nikodroid May 18 '13 at 23:25
  • 1
    Seems to be a permission issue. – Alejandro Colorado May 18 '13 at 23:34
  • Fixed it by changing permissions/ownership. Worked without any glitches after it :) – nikodroid May 19 '13 at 09:32
  • 1
    By the way, it would be nice if you marked my answer as correct. – Alejandro Colorado May 19 '13 at 11:45
0

Make sure the content of

/usr/share/applications/android-studio/bin

are executable (the directory as well) by the group. (probably the group users). Then make sure your user is in that group.

njzk2
  • 38,969
  • 7
  • 69
  • 107