Android Studio doesn't open as root

terex@Terminator:/android-studio/bin$ sudo ./studio.sh
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.

But opens when not using sudo.

terex@Terminator:/android-studio/bin$ ./studio.sh
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=350m; support was removed in 8.0
[  85000]   WARN - openapi.wm.impl.ToolWindowImpl - ToolWindow icons should be 13x13.
Please fix jar:file:/android-studio/lib/resources.jar!/artwork/toolWindowProject_AS.png 

I might have meshed up something during java installation.

Further more, AVD after starting shows android and doesn't show anything more (I left my laptop awake for whole night and until morning the avd won't get started but only show ANDROID).

Everything was fine with Windows.


I don't think you are supposed to open Android Studio as root anyways, only sudo programs if you really need to, even if you think they are safe.

Anyways, I think this is due to your environment variables not being set when you run the script as root. You may have to set your JAVA_HOME variable in the script (before launching Android Studio)

Run this command in wherever you installed Android Studio (the folder with the studio.sh file and DON'T RUN AS ROOT): sed -i "1iJAVA_HOME='$JAVA_HOME'" studio.sh

This will make sure that your JAVA_HOME variable is set properly before Android Studio launches.

| improve this answer | |
  • Bingo. Thanks for this. The problem was indeed not to need to sudo the program. I had installed Android Studio into /usr/local and did sudo ./studio.sh to start it but it complained it couldn't find the JAVA_HOME and JDK_HOME variables. But when I installed it into my home folder, it worked without any problem. – Nav Dec 20 '15 at 9:55

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.