Android 键盘(AOSP)在 Android O 模拟器上一直停止

Android Keyboard (AOSP) keeps stopping with Android O emulator

我 运行 在使用 Android 键盘和 Android O 模拟器时遇到了这个问题。它总是给我错误说

"Android Keyboard (AOSP) has stopped"

当我尝试按下 Android 键盘上的“?123”按钮时,键盘自行关闭。

仅当我在 Android Studio 3.0 Canary 7 中使用带有 API 26 (Android O) 的模拟器时才会出现此问题。 将错误信息粘贴到下面。

08-15 16:19:41.249 12833-12833/com.android.inputmethod.latin E/AndroidRuntime: FATAL EXCEPTION: main
                                                                           Process: com.android.inputmethod.latin, PID: 12833
                                                                           com.android.inputmethod.keyboard.KeyboardLayoutSet$KeyboardLayoutSetException: java.lang.IllegalArgumentException: Empty keySpec at Binary XML file line #39
                                                                               at com.android.inputmethod.keyboard.KeyboardLayoutSet.getKeyboard(KeyboardLayoutSet.java:207)
                                                                               at com.android.inputmethod.keyboard.KeyboardSwitcher.setKeyboard(KeyboardSwitcher.java:153)
                                                                               at com.android.inputmethod.keyboard.KeyboardSwitcher.setSymbolsKeyboard(KeyboardSwitcher.java:258)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardState.setSymbolsKeyboard(KeyboardState.java:318)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardState.toggleAlphabetAndSymbols(KeyboardState.java:262)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardState.onPressSymbol(KeyboardState.java:411)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardState.onPressKey(KeyboardState.java:370)
                                                                               at com.android.inputmethod.keyboard.KeyboardSwitcher.onPressKey(KeyboardSwitcher.java:194)
                                                                               at com.android.inputmethod.latin.LatinIME.onPressKey(LatinIME.java:1666)
                                                                               at com.android.inputmethod.keyboard.PointerTracker.callListenerOnPressAndCheckKeyboardLayoutChange(PointerTracker.java:265)
                                                                               at com.android.inputmethod.keyboard.PointerTracker.onDownEventInternal(PointerTracker.java:687)
                                                                               at com.android.inputmethod.keyboard.PointerTracker.onDownEvent(PointerTracker.java:644)
                                                                               at com.android.inputmethod.keyboard.PointerTracker.processMotionEvent(PointerTracker.java:604)
                                                                               at com.android.inputmethod.keyboard.MainKeyboardView.processMotionEvent(MainKeyboardView.java:723)
                                                                               at com.android.inputmethod.keyboard.MainKeyboardView.onTouchEvent(MainKeyboardView.java:710)
                                                                               at android.view.View.dispatchTouchEvent(View.java:11721)
                                                                               at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
                                                                               at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2593)
                                                                               at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
                                                                               at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2593)
                                                                               at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
                                                                               at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2593)
                                                                               at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
                                                                               at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2593)
                                                                               at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
                                                                               at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2593)
                                                                               at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
                                                                               at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2593)
                                                                               at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2961)
                                                                               at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2593)
                                                                               at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:445)
                                                                               at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1828)
                                                                               at android.app.Dialog.dispatchTouchEvent(Dialog.java:815)
                                                                               at android.inputmethodservice.SoftInputWindow.dispatchTouchEvent(SoftInputWindow.java:93)
                                                                               at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:407)
                                                                               at android.view.View.dispatchPointerEvent(View.java:11960)
                                                                               at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4776)
                                                                               at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4590)
                                                                               at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
                                                                               at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4181)
                                                                               at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4147)
                                                                               at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4274)
                                                                               at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4155)
                                                                               at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4331)
                                                                               at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
                                                                               at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4181)
08-15 16:19:41.249 12833-12833/com.android.inputmethod.latin E/AndroidRuntime:     at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4147)
                                                                               at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4155)
                                                                               at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4128)
                                                                               at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6642)
                                                                               at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6616)
                                                                               at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6577)
                                                                               at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6745)
                                                                               at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
                                                                               at android.os.MessageQueue.nativePollOnce(Native Method)
                                                                               at android.os.MessageQueue.next(MessageQueue.java:325)
                                                                               at android.os.Looper.loop(Looper.java:142)
                                                                               at android.app.ActivityThread.main(ActivityThread.java:6541)
                                                                               at java.lang.reflect.Method.invoke(Native Method)
                                                                               at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
                                                                            Caused by: java.lang.IllegalArgumentException: Empty keySpec at Binary XML file line #39
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardBuilder.load(KeyboardBuilder.java:175)
                                                                               at com.android.inputmethod.keyboard.KeyboardLayoutSet.getKeyboard(KeyboardLayoutSet.java:227)
                                                                               at com.android.inputmethod.keyboard.KeyboardLayoutSet.getKeyboard(KeyboardLayoutSet.java:204)
                                                                                ... 60 more
                                                                            Caused by: com.android.inputmethod.latin.utils.XmlParseUtils$ParseException: Empty keySpec at Binary XML file line #39
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardBuilder.parseKey(KeyboardBuilder.java:482)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardBuilder.parseRowContent(KeyboardBuilder.java:362)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardBuilder.parseDefault(KeyboardBuilder.java:798)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardBuilder.parseSwitchInternal(KeyboardBuilder.java:609)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardBuilder.parseSwitchRowContent(KeyboardBuilder.java:595)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardBuilder.parseRowContent(KeyboardBuilder.java:368)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardBuilder.parseMerge(KeyboardBuilder.java:578)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardBuilder.parseIncludeInternal(KeyboardBuilder.java:557)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardBuilder.parseIncludeRowContent(KeyboardBuilder.java:518)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardBuilder.parseRowContent(KeyboardBuilder.java:366)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardBuilder.parseKeyboardContent(KeyboardBuilder.java:310)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardBuilder.parseMerge(KeyboardBuilder.java:576)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardBuilder.parseIncludeInternal(KeyboardBuilder.java:557)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardBuilder.parseIncludeKeyboardContent(KeyboardBuilder.java:513)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardBuilder.parseKeyboardContent(KeyboardBuilder.java:315)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardBuilder.parseKeyboard(KeyboardBuilder.java:229)
                                                                               at com.android.inputmethod.keyboard.internal.KeyboardBuilder.load(KeyboardBuilder.java:172)
                                                                                ... 62 more

是AndroidO端的bug吗?

这是 AOSP 8.0 中 LatinIME 输入法中的错误(他们可能没有发现它,因为品牌 Android 中未使用 AOSP 键盘)。

修复在这里: https://android-review.googlesource.com/#/c/platform/packages/inputmethods/LatinIME/+/469478/