Search code examples
androidandroid-emulator

Android emulator doesn't take keyboard input - SDK tools rev 20


I've upgraded the SDK tools to revision 20 (from 18) and since the upgrade, the emulator doesn't seem to accept input from laptop's keyboard. But only using the emulator's own 'soft' keyboard (that appears when an input field is focused).

I've tried reinstalling the SDK tools (and the whole SDK for that matter), uninstalled and reinstalled Eclipse Android plugins, re-created emulator devices. But none of that seem to help and its driving me mad. Its hopeless to key-in using a laptop's trackpad.

Has anyone encountered this problem?


Solution

  • Update

    As of SDK rev 21 the Android Virtual Device Manager has an improved UI which resolves this issue. I have highlighted some of the more important configuration settings below:

    enter image description here

    If you notice that the soft (screen-based) main keys Back, Home, etc. are missing from your emulator you can set hw.mainKeys=no to enable them.

    enter image description here

    Original answer

    Even though the developer documentation says keyboard support is enabled by default it doesn't seem to be that way in SDK rev 20. I explicitly enabled keyboard support in my emulator's config.ini file and that worked!

    Add: hw.keyboard=yes

    To: ~/.android/avd/<emulator-device-name>.avd/config.ini

    Similarly, add hw.dPad=yes if you wish to use the arrow-keys to navigate the application list.

    Reference: http://developer.android.com/tools/devices/managing-avds-cmdline.html#hardwareopts

    On Mac OS and Linux you can edit all of your emulator configurations with one Terminal command:

    for f in ~/.android/avd/*.avd/config.ini; do echo 'hw.keyboard=yes' >> "$f"; done


    On a related note, if your tablet emulator is missing the BACK/HOME buttons, try selecting WXGA800 as the Built-in skin in the AVD editor: enter image description here

    Or by manually setting the skin in config.ini:

    skin.name=WXGA800
    skin.path=platforms/android-16/skins/WXGA800
    

    (example is for API 16)