Android Studio & ibus-daemon interactions

tl;dr: On Linux systems (where the ibus-daemon is active), there are scenarios where the IDE will stop responding to keyboard input or start inputting random characters. This document provides some workarounds for those bugs.

The bug seems to be triggered by some missing synchronization between IBus (the server) and Xlib + AWT (the client JVM), exposed by a combination of a quick succession of key presses and the client’s slower event handling. The bug has already been reported upstream:

Workaround #1: Force ibus in synchronous mode

$ IBUS_ENABLE_SYNC_MODE=1 ibus-daemon -xrd

Do this preferably before starting Studio. This workaround was suggested in for a different Java application facing the same problems.

Workaround #2: Disable IBus input in Studio

$ XMODIFIERS= ./bin/

This will only disable input methods for Studio, not the other applications. Restarting the daemon while Studio is running (‘ibus-daemon -rd’) effectively disables the input methods for all other applications, and can also crash Studio's JVM with a segmentation fault.

Double-check the shortcut bindings

Run ‘ibus-setup’ and check Keyboard Shortcuts / Next input method. Make sure it’s not Ctrl+space, which is also the code completion shortcut for Studio and other IDEs. Change it to Super+space or whatever seems appropriate. Ubuntu 14.04 (Trusty) makes Super+space the default shortcut, but it could be the case that settings from a previous version were kept around.