Friday, 19 July 2013

Creating an Android Studio Desktop File for launching on your panel or toolbar in GNU/Linux

I spent a while (read: too much time) trying to get Android Studio launching on my KDE panel via an icon.

The program would not launch, even after editing the studio.sh script so the user wouldn't have to press the key. Since I compiled and installed IcedTea Java 7, it would always warn me before launch. Oracle Java is recommended for running Android Studio, but I take some issue with Oracle as a company, so I would prefer not to use it. Plus, on Gentoo, the package manager requires the manual downloading of oracle's java.bin files because they do not allow Gentoo to carry it in their package repository due to copyright or some crap like that.

Anyway, back to the application launching: even when exporting JAVA_HOME in my .bashrc file (which gets run every login shell), the application would fail to run. The fix for this is to manually add the path to the EXEC= line in the .desktop file. Here is mine as an example:

[Desktop Entry]
Comment=
Exec=JDK_HOME="/usr/lib/jvm/icedtea-7/" /home/celestia/Programs/android-studio/bin/studio.sh
Icon=/home/celestia/Pictures/Icons/android.png
Name=AndroidStudio
NoDisplay=false
Path[$e]=
StartupNotify=true
Terminal=0
TerminalOptions=
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=

I used the KDE Menu Editor to generate the template, but regardless of how you create your .desktop file, it's the EXEC line you need.
If your paths are set up system-wide, I doubt there will be any errors when you run studio.sh without the JDK_HOME path.

Hope this helps.
Cheers!

No comments:

Post a Comment