Add an Android Studio icon on Ubuntu

How to add a desktop shortcut on Gnome 3 to launch Android Studio (Ubuntu 16.04)
Add an Android Studio icon on Ubuntu

This tip explains two ways to add a desktop icon to launch Android Studio from a Gnome 3 environment: activate or create icons on the desktop.

Prerequisites

1/ Activate icons on the desktop

Not all environments on Linux allow desktop icons by default and neither does Gnome 3 under Ubuntu 16.04.

To allow icons you should use the gnome-tweak-tool application

First, if gnome-tweak-tool is not available on your system type the following command from a terminal:

$ sudo apt-get install gnome-tweak-tool

Then launch the gnome-tweak-tool application :

$ gnome-tweak-tool

Finally, in the menu of the application go to the Desktop section and activate the icons.

Desktop menu of the gnome-tweak-tool application GUI
Desktop menu of the gnome-tweak-tool application GUI

Source: https://www.linuxhelp.com/how-to-install-gnome-tweak-tool-on-ubuntu-16-04

2/ Create the icon

There are two ways to create an icon:

  1. Using a .desktop extension file.
  2. Using a script

A/ Using a .desktop file

A.1/ Create an android.desktop file

In folder "~/Desktop" (can be called differently depending on the language of your environment like "~/Bureau" for French), create a file called android.desktop. In this file put the following text:

[Desktop Entry]
Version=1.0
Type=Application
Name=Android Studio
Comment=Android Studio
Exec=/opt/android-studio/bin/studio.sh
Icon=emblem-dropbox-syncing
Path=
Terminal=false
StartupNotify=false

Adapt the code above regarding the Android Studio installation path ("Exec" field). On our environment Android Studio application is located in "/opt/android-studio" and the script to launch it is "/opt/android-studio/bin/studio.sh"

A.2/ Authorize file execution

If a message Untrusted application launcher is displayed on executing the script from the desktop, it is necessary to allow the .desktop file to be executed. Proceed as follows:

  • Right-click on the previously icon and select the menu Properties.
  • Select the tab Permissions
  • Tick the Execute box "Allow executing file as program"

View of Desktop icon properties permissions setting
View of Desktop icon properties permissions setting

Here you are! A neat icon is now available on your desktop to launch Android Studio.

You can proceed to the lessons of the Developer Center section now or read the Tips and tricks articles around Android Studio use.

View of a desktop with Android Studio icon
View of a desktop with Android Studio icon

B/ Using a script file

B.1/ Create a file android.sh

Create a script file on the "~/Desktop" folder, name this file "android.sh" and add the following content:

#!/bin/bash
nohup /opt/android-studio/bin/studio.sh &

You could also create a symbolic link to the “studio.sh” script which is located in "/opt/android-studio/bin/studio.sh" on our install.

$ cd ~/Desktop
$ ln -s /opt/android-studio/bin/studio.sh studio.sh

B.2/ Allow script execution

To increase security Gnome does not activate a script files from the graphical environment. You need to allow this execution manually.

  • Use dconf-editor application ( Hit Alt+F2, type dconf-editor and hit Enter );
  • In dconf editor window go to menu org > gnome > nautilus > preferences;
  • On the right window pane select entry executable-text-activation;
  • Click on the field on the right and from the drop-down menu that is displayed select:
    • launch to launch scripts as programs

      or

    • ask to ask what to do via a dialogue

View of the dconf-editor window
View of the dconf-editor window

Ubuntu forum source

Now you have a shortcut on your desktop to launch your Android Studio IDE. Enjoy and explore the lessons of the Developer Center section or read the Tips and tricks articles around Android Studio use.

View of a desktop with icons
View of a desktop with icons

Add a shortcut in the launcher

If you prefer to access Android Studio from the dash or add an icon as a favourite in the launcher, this is pretty simple either. Follow the steps below :

  • Open Android Studio,
  • Click on Tools menu -> Create Desktop Entry.

This should create an entry on the dash.

Android Studio on dashboard
Android Studio on dashboard

  • Launch Android Studio
  • On the launcher, right click on the Android Studio logo
  • In the menu, click on Add to Favourites

The Android Studio icon should now be available in the application launcher.

Add Android Studio to Favourites
Add Android Studio to Favourites

Green Guy with glasses
Louis-Gabriel POUILLOT
Senior Software Engineer