[fixed] Android Studio has generic gear icon in Ubuntu dock
The issue where Android Studio’s icon appears correctly in the Ubuntu application menu/screen but displays incorrectly (e.g., as a generic gear icon or a duplicate/wrong icon) on the dock/panel when the application is open is often caused by a mismatch between the .desktop file and the window’s WM_CLASS property.
This is a common problem in Ubuntu, particularly with applications like Android Studio that are launched via a shell script, which then spawns a Java process. Here is how I fixed it in my case.
my solution: re-create desktop entry/file using Android Studio 🔗
I recorded my solution in a video on YouTube, if you like watching videos more than reading, here it is.
What I did is simply:
- create a new
.desktopentry file using Android Studio by clicking onToolsin the Android Studio menu, then clickingCreate Desktop Entry. This creates a new entry file. - remove old
.desktopentry files.
solution: fix the Android Studio icon on the Ubuntu dock 🔗
Launch Android Studio and Find the WM_CLASS 🔗
- Open Android Studio from the terminal or the application menu.
- Press Alt + F2 to open the “Run a Command” dialog.
- Type
lg(short for “Looking Glass”) and press Enter. This opens GNOME’s integrated debugger and inspector tool. - In the Looking Glass window, click on the Windows tab.
- Locate the Android Studio window in the list and note the wmclass value. It is typically something like
jetbrains-studio.
Locate or Create the .desktop File 🔗
- Check for an existing
.desktopfile in one of these locations:- User-specific:
~/.local/share/applications/ - System-wide:
/usr/share/applications/
- User-specific:
- Look for a file named
jetbrains-android-studio.desktop,jetbrains-studio.desktop,studio.desktopor similar. - If it doesn’t exist, you can create one manually or generate it via Android Studio:
- Open Android Studio.
- Go to Tools > Create Desktop Entry in the menu. This should create a
.desktopfile in~/.local/share/applications/.
Edit the .desktop File 🔗
- Open the
.desktopfile (e.g.,~/.local/share/applications/jetbrains-android-studio.desktop) with a text editor, such as nano, gedit, vim, or nvim:
nano ~/.local/share/applications/jetbrains-android-studio.desktop
- Ensure the file contains the correct Icon and Exec paths. A typical
.desktopfile looks like this:
[Desktop Entry]
Version=1.0
Type=Application
Name=Android Studio
Exec=/path/to/android-studio/bin/studio.sh %f
Icon=/path/to/android-studio/bin/studio.png
Categories=Development;IDE;
Terminal=false
StartupNotify=true
StartupWMClass=jetbrains-android-studio
or
[Desktop Entry]
Version=1.0
Type=Application
Name=Android Studio
Exec=/path/to/android-studio/bin/studio %f
Icon=/path/to/android-studio/bin/studio.svg
Categories=Development;IDE;
Terminal=false
StartupNotify=true
StartupWMClass=jetbrains-studio
- Add or modify the StartupWMClass line to match the wmclass value you found in step 1 (e.g.,
StartupWMClass=jetbrains-studio) if it is not already correct. - Verify that the Icon path points to the correct icon file (e.g.,
/path/to/android-studio/bin/studio.png). If you’re unsure, you can specify the full path to the icon file in the Android Studio installation directory. - save the file and exit.
Update the Desktop Database 🔗
- Run the following command to ensure the system recognizes the updated
.desktopfile:
update-desktop-database ~/.local/share/applications/
Sometimes, it does not need to be run at all.
Pin the Application to the Dock 🔗
- Launch Android Studio from the application menu (not the dock yet).
- Right-click the Android Studio icon in the dock (it should now show the correct icon).
- Select Add to Favorites to pin it to the dock.
Check for Conflicting .desktop Files 🔗
- Ensure there are no duplicate
.desktopfiles for Android Studio in~/.local/share/applications/or/usr/share/applications/. If duplicates exist, the local file (~/.local/share/applications/) takes precedence. Delete or rename any conflicting files. - you can check for duplicates with:
ls ~/.local/share/applications/ | grep android
ls ~/.local/share/applications/ | grep studio
ls /usr/share/applications/ | grep android
ls /usr/share/applications/ | grep studio
Restart the GNOME Shell (Optional) 🔗
- If the icon still doesn’t display correctly, restart the GNOME Shell to refresh the desktop environment:
killall -HUP gnome-shell
- Alternatively, log out and log back in, or reboot the system.
Additional Notes 🔗
Why This Happens? 🔗
When Android Studio launches, the studio.sh script starts a Java process, which creates a window with a WM_CLASS that doesn’t match the .desktop file by default. GNOME Shell fails to associate the window with the correct icon, resulting in a generic or duplicate icon on the dock. Adding the StartupWMClass entry resolves this by linking the window’s WM_CLASS to the .desktop file.
Icon Path 🔗
If the icon still doesn’t appear, ensure the Icon field in the .desktop file points to a valid image file (PNG or SVG). You can also use an icon from your system’s icon theme (e.g., Icon=android-studio) if the icon is installed in /usr/share/icons/ or ~/.local/share/icons/.
Ubuntu Version associated with this issue 🔗
This issue is common across Ubuntu versions (e.g., 20.04, 22.04, 24.04) and is particularly prevalent with JetBrains IDEs like Android Studio due to their Java-based architecture. The steps above are applicable to most recent Ubuntu releases using GNOME.
Troubleshooting 🔗
Duplicate Icons 🔗
If two icons appear on the dock (one correct, one generic), it’s likely due to a mismatch in StartupWMClass or multiple .desktop files. Double-check the WM_CLASS and remove any conflicting .desktop files.
No Icon File 🔗
If the icon file is missing, copy studio.png from the Android Studio installation directory (e.g., /path/to/android-studio/bin/studio.png) to ~/.local/share/icons/ and update the Icon field to point to it.
Still Not Working 🔗
If the issue persists, try launching Android Studio from the terminal (/path/to/android-studio/bin/studio.sh) and check for error messages. Also, verify that the JAVA_HOME environment variable is set correctly, as it can affect Android Studio’s behavior:
echo $JAVA_HOME
If unset, configure it in ~/.bashrc or ~/.zshrc :
export JAVA_HOME=/path/to/java
or ~/.config/fish/config.fish:
set -gx JAVA_HOME "/path/to/java"
If you still face the same issue, contact me on YouTube , Twitter (x) , LinkedIn , and GitHub .
If you know a person who can benefit from this information, send them a link of this post.