Cannot run android studio as sudo

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Asim

Cannot run android studio as sudo

Post by Asim »

Hello All

I cannot seem to run android studio using the sudo command (I like to run this program as root all the time), but when I do sudo /bin/studio.sh I get this:

ERROR: Cannot start Android Studio
No JDK found. Please validate either STUDIO_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation.

I can run it as a normal user and it works. Now searching Google people say it's a permission issue I have tried one solution from stack, but it has not worked:

http://stackoverflow.com/questions/1662 ... g-on-linux

My android studio is located at /opt/android studio

I have done chown -R root:root android-studio (this did not work)

in my ~/.profile file I got the variables in like so.

export JAVA_HOME=/usr/java/jdk1.7.0_71
export JRE_HOME=/usr/java/jdk1.7.0_71/jre
export STUDIO_JDK=$JAVA_HOME
export JDK_HOME=$JAVA_HOME
export PATH=$PATH:$JAVA_HOME:$JRE_HOME:$JAVA_HOME/bin


I also got them in etc/environment like so.

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
STUDIO_JDK="/usr/java/jdk1.7.0_71"
JAVA_HOME="/usr/java/jdk1.7.0_71"
JDK_HOME="/usr/java/jdk1.7.0_71"

if I do whereis java I get the top directories, I can run all this as non-root but, using sudo command I cannot, what is going on?

thanks
Asim
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
austin.texas
Level 20
Level 20
Posts: 12003
Joined: Tue Nov 17, 2009 3:57 pm
Location: at /home

Re: Cannot run android studio as sudo

Post by austin.texas »

Try gksudo instead of sudo
Mint 18.2 Cinnamon, Quad core AMD A8-3870 with Radeon HD Graphics 6550D, 8GB DDR3, Ralink RT2561/RT61 802.11g PCI
Linux Linx 2018
Asim

Re: Cannot run android studio as sudo

Post by Asim »

austin.texas wrote:Try gksudo instead of sudo

Hi got the same issue.
DrHu

Re: Cannot run android studio as sudo

Post by DrHu »

Since you can run it as somebody, why not check the settings within Android SDK itself, such as below..
http://jstdvlpit.com/2013/06/15/error-c ... -continue/

http://stackoverflow.com/questions/2340 ... oid-studio

More comprehensive info regards JDK/Android and JDK
http://www.cnx-software.com/2013/05/16/ ... plication/

Also you might check the java version on the command line under the userIDs you have to see if it actually know where java and JDK is ??
http://www.mysamplecode.com/2012/05/che ... -mint.html
http://www.cyberciti.biz/faq/ubuntu-lin ... k-version/

I also notice that you use a space character in the location of Android Studio
--can Linux even recognize that as a valid directory/folder location ??

About /opthttp://www.linuxjournal.com/magazine/pointcoun ... /usr/local, I might not have used that location. Or I would check this status..
  • Bill: Exponential? Only if you're installing a crazy amount of software, man. I rather like knowing that if I'm going to be building, say, a Java application server, that my JDK is always in /opt/jdk (I typically have a symlink that points to the real JDK, like /opt/jdk_sun_1.6.0.17. That way, JAVA_HOME is always /opt/jdk. Any other packages, say a custom-compiled apache, can live in /opt/apache.
I think you are going to have to look carefully at the JDK and JAVA locations, setups..
Locked

Return to “Other topics”