Android 模拟器不接受键盘输入 - SDK 工具 20 版
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11235370/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android emulator doesn't take keyboard input - SDK tools rev 20
提问by epsilonpsi
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).
我已将 SDK 工具升级到修订版 20(从 18 版),并且自升级以来,模拟器似乎不接受来自笔记本电脑键盘的输入。但只能使用模拟器自己的“软”键盘(在输入字段聚焦时出现)。
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.
我尝试重新安装 SDK 工具(以及整个 SDK),卸载并重新安装 Eclipse Android 插件,重新创建模拟器设备。但这些似乎都没有帮助,这让我发疯。使用笔记本电脑的触控板输入是没有希望的。
Has anyone encountered this problem?
有没有人遇到过这个问题?
回答by James Wald
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:
从 SDK rev 21 开始,Android 虚拟设备管理器有一个改进的 UI 来解决这个问题。我在下面强调了一些更重要的配置设置:
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.
如果您发现该软(基于屏幕)主键Back
,Home
等等都从你的模拟器丢失,您可以设置hw.mainKeys=no
启用它们。
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!
尽管开发人员文档说默认情况下启用键盘支持,但在 SDK rev 20 中似乎并非如此。我在模拟器的 config.ini 文件中明确启用了键盘支持,并且奏效了!
Add: hw.keyboard=yes
添加: hw.keyboard=yes
To: ~/.android/avd/<emulator-device-name>.avd/config.ini
到: ~/.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.
同样,hw.dPad=yes
如果您希望使用箭头键导航应用程序列表,请添加。
Reference: http://developer.android.com/tools/devices/managing-avds-cmdline.html#hardwareopts
参考: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:
在 Mac OS 和 Linux 上,您可以使用一个终端命令编辑所有模拟器配置:
for f in ~/.android/avd/*.avd/config.ini; do echo 'hw.keyboard=yes' >> "$f"; done
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 WXGA800as the Built-in skin in the AVD editor:
在相关说明中,如果您的平板电脑模拟器缺少 BACK/HOME 按钮,请尝试在 AVD 编辑器中选择WXGA800作为内置皮肤:
Or by manually setting the skin in config.ini:
或者通过在 config.ini 中手动设置皮肤:
skin.name=WXGA800
skin.path=platforms/android-16/skins/WXGA800
(example is for API 16)
(示例适用于 API 16)
回答by Romin
Confirmed. I had the same problem after upgrading to Tools version 20. I had to Edit the AVD to add an option as follows:
确认的。升级到工具版本 20 后,我遇到了同样的问题。我必须编辑 AVD 以添加如下选项:
- 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.
- 从 Eclipse,转到 AVD Mananger。
- 选择特定的 AVD 并单击编辑
- 转到硬件部分,单击新建。
- 选择属性名称:键盘支持
- 默认情况下,它添加了一个值 'no'。只需单击值列并将其更改为“是”。
- 再次单击“编辑 AVD”。
This will add a property hw.keyboard=yes in config.ini file for the AVD.
这将在 AVD 的 config.ini 文件中添加一个属性 hw.keyboard=yes。
You also have to set hw.mainKeys = yes
您还必须设置 hw.mainKeys = yes
回答by Hong
In Android Studio, open AVD Manager (Tools > Android > AVD Manager).
Tap the Edit button of the emulator:
在 Android Studio 中,打开 AVD 管理器(工具 > Android > AVD 管理器)。点击模拟器的编辑按钮:
Select "Show Advanced Settings"
选择“显示高级设置”
Check "Enable keyboard input"
勾选“启用键盘输入”
Click Finish and start the emulator to enjoy the keyboard input.
单击完成并启动模拟器以享受键盘输入。
回答by Joel Pelaez
Look in AVD Manager, select the AVD and click in Edit. In Hardware section: click in "New" and search for "Keyboard support" and add with OK button and set the value to "yes" and save changes with "Edit AVD"
在 AVD 管理器中查看,选择 AVD 并单击编辑。在硬件部分:单击“新建”并搜索“键盘支持”并使用“确定”按钮添加并将值设置为“是”并使用“编辑 AVD”保存更改
回答by Vincy
Google wanted to give some more headache to the developers.
谷歌想让开发人员更头疼。
So, what you have to do now is edit your AVD and add "Keyboard Support" for it in the Hardware section and change the value to "Yes"
因此,您现在要做的是编辑您的 AVD 并在硬件部分为其添加“键盘支持”并将值更改为“是”
回答by Amit Yaron
In your home folder /.android/avd//config.ini add the line hw.keyboard=yes
在您的主文件夹 /.android/avd//config.ini 添加行 hw.keyboard=yes
回答by PbxMan
Just in case somebody finds it usefull.
以防万一有人觉得它有用。
I had a problem with the KEYCODE_DPAD_UPit belongs to the trackBall. to solve this change your avdfolder/config.ini hw.trackBall=yesand push DEL or F6
我对属于轨迹球的KEYCODE_DPAD_UP有问题。要解决此更改,请更改您的 avdfolder/ config.ini hw.trackBall=yes并按 DEL 或 F6
回答by Zon
Restarting the emulatorhelps sometimes when typing is unavailable - despite keyboard input being enabled for your Android Virtual Device.
有时在无法输入时重新启动模拟器会有所帮助 - 尽管您的 Android 虚拟设备已启用键盘输入。
回答by Witold
Here is some workaround that actually worked for me, it is the same solution as in the most popular answer - just add hw.keyboard=yes to config.ini but since this didn't workfor me I additionally
这里有一些实际对我有用的解决方法,它与最流行的答案中的解决方案相同 - 只需将 hw.keyboard=yes 添加到 config.ini 但由于这对我不起作用,我另外
- renamed config.ini (any name will do) to something like consssssfig.ini
- restarted emulator (obviously it didn't start)
- renamed config.ini back again
- (I am not sure if relevant) I added this new parameter (hw.keyboard=yes) at the beggining of config.ini file
- 将 config.ini(任何名称都可以)重命名为类似 consssssfig.ini 的内容
- 重新启动模拟器(显然它没有启动)
- 再次重命名 config.ini
- (我不确定是否相关)我在 config.ini 文件的开头添加了这个新参数(hw.keyboard=yes)
回答by Eric Cloninger
Look for the hidden .android folder in your user home folder. You might rename or delete this folder, recreate your AVD, and restart the emulator. It could be there is a .ini file in that folder that has that setting munged.
在您的用户主文件夹中查找隐藏的 .android 文件夹。您可以重命名或删除此文件夹,重新创建您的 AVD,然后重新启动模拟器。可能是该文件夹中有一个 .ini 文件,该文件已修改了该设置。