Android emulator doesn't take keyboard input

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?


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:

在这里输入图像描述

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.

在这里输入图像描述

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: 在这里输入图像描述

Or by manually setting the skin in config.ini:

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

(example is for API 16)


Confirmed. I had the same problem after upgrading to Tools version 20. I had to Edit the AVD to add an option as follows:

  • From Eclipse, Go to AVD Mananger.
  • Select the particular AVD and click on Edit
  • Go to the Hardware section, click on New.
  • Select the Property Name : Keyboard Support
  • By default, it is added with a value of 'no'. Just click on the value column and change it to 'yes'.
  • Click on Edit AVD again.
  • This will add a property hw.keyboard=yes in config.ini file for the AVD.


    In Android Studio, open AVD Manager (Tools > Android > AVD Manager). Tap the Edit button of the emulator: 在这里输入图像描述

    Select "Show Advanced Settings" 在这里输入图像描述

    Check "Enable keyboard input" 在这里输入图像描述

    Click Finish and start the emulator to enjoy the keyboard input.

    链接地址: http://www.djcxy.com/p/90536.html

    上一篇: Android 4.0.3键盘超出底部显示边框

    下一篇: Android模拟器不需要键盘输入