gpt4 book ai didi

java - 带有 Android 10 的小米上 TextInputLayout 中的 NullPointerException

转载 作者:行者123 更新时间:2023-12-04 13:33:36 24 4
gpt4 key购买 nike

我最近开始在我的 android 应用程序中使用 TextInputLayout。之后,开始出现奇怪的 NullPointerException 错误。这些错误仅发生在带有 XiaomiAndroind 10 设备上。

Fatal Exception: java.lang.NullPointerException
Attempt to invoke direct method 'void android.widget.Editor$SelectionModifierCursorController.initDrawables()' on a null object reference
android.widget.Editor$SelectionModifierCursorController.access$300
无法重现错误(我没有小米设备)。上网搜索发现,在 TextInputLayout字段中尝试输入email时会出现这个错误。
网上有一个 React Native 的解决方案: https://github.com/facebook/react-native/issues/27204
不幸的是,我还没有找到 Java 的解决方案。
来自 Crashlytics 的屏幕截图:
Crashlytics
完整报告:
android.widget.Editor$SelectionModifierCursorController.access$300 (Editor.java:6709)
android.widget.Editor.getEmailPopupWindow (Editor.java:1471)
android.widget.Editor.showEmailPopupWindow (Editor.java:1479)
android.widget.Editor.handleEmailPopup (Editor.java:1458)
android.widget.Editor.updateCursorPosition (Editor.java:2101)
android.widget.TextView.getUpdatedHighlightPath (TextView.java:7823)
android.widget.TextView.onDraw (TextView.java:8008)
android.view.View.draw (View.java:21594)
android.view.View.updateDisplayListIfDirty (View.java:20437)
android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4456)
android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4429)
android.view.View.updateDisplayListIfDirty (View.java:20388)
android.view.View.draw (View.java:21312)
android.view.ViewGroup.drawChild (ViewGroup.java:4472)
android.view.ViewGroup.dispatchDraw (ViewGroup.java:4231)
android.view.View.draw (View.java:21601)
com.google.android.material.textfield.TextInputLayout.draw (TextInputLayout.java:3064)
android.view.View.updateDisplayListIfDirty (View.java:20437)
android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4456)
android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4429)
android.view.View.updateDisplayListIfDirty (View.java:20388)
android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4456)
android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4429)
android.view.View.updateDisplayListIfDirty (View.java:20388)
android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4456)
android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4429)
android.view.View.updateDisplayListIfDirty (View.java:20388)
android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4456)
android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4429)
android.view.View.updateDisplayListIfDirty (View.java:20388)
android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4456)
android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4429)
android.view.View.updateDisplayListIfDirty (View.java:20388)
android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4456)
android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4429)
android.view.View.updateDisplayListIfDirty (View.java:20388)
android.view.ViewGroup.recreateChildDisplayList (ViewGroup.java:4456)
android.view.ViewGroup.dispatchGetDisplayList (ViewGroup.java:4429)
android.view.View.updateDisplayListIfDirty (View.java:20388)
android.view.ThreadedRenderer.updateViewTreeDisplayList (ThreadedRenderer.java:575)
android.view.ThreadedRenderer.updateRootDisplayList (ThreadedRenderer.java:581)
android.view.ThreadedRenderer.draw (ThreadedRenderer.java:654)
android.view.ViewRootImpl.draw (ViewRootImpl.java:3844)
android.view.ViewRootImpl.performDraw (ViewRootImpl.java:3635)
android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2955)
android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1865)
android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:8029)
android.view.Choreographer$CallbackRecord.run (Choreographer.java:969)
android.view.Choreographer.doCallbacks (Choreographer.java:793)
android.view.Choreographer.doFrame (Choreographer.java:728)
android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:954)
android.os.Handler.handleCallback (Handler.java:883)
android.os.Handler.dispatchMessage (Handler.java:100)
android.os.Looper.loop (Looper.java:224)
android.app.ActivityThread.main (ActivityThread.java:7509)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:539)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:995)

最佳答案

这就是我为修复崩溃所做的。它会在编辑电子邮件地址时禁用光标,但不会崩溃。

if (android.os.Build.MANUFACTURER.equals("Xiaomi", ignoreCase = true) &&
android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.Q) {
editText.isCursorVisible = false
}

关于java - 带有 Android 10 的小米上 TextInputLayout 中的 NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63558592/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com