自定义键盘不适用于Android P Beta [英] Custom Keyboard not working on Android P Beta

查看:145
本文介绍了自定义键盘不适用于Android P Beta的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用自定义键盘"时,Android P Beta出现异常,直到Android Oreo一切正常,但最近崩溃了.只需尝试找出哪个类可能是异常的原因.当前无法访问完整的自定义键盘代码,因此无法发布该代码.

When I try to use Custom Keyboard got an exception on Android P Beta, everything is working fine until Android Oreo but recently got a crash. Just try to figure out which class might be responsible for the exception. Currently unable to access complete custom keyboard code so not posting the code.

java.lang.IllegalArgumentException: Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed
    at android.graphics.Canvas.checkValidClipOp(Canvas.java:779)
    at android.graphics.Canvas.clipRect(Canvas.java:826)
    at android.inputmethodservice.KeyboardView.onBufferDraw(KeyboardView.java:666)
    at android.inputmethodservice.KeyboardView.onDraw(KeyboardView.java:647)
    at android.view.View.draw(View.java:20205)
    at android.view.View.updateDisplayListIfDirty(View.java:19080)
    at android.view.View.draw(View.java:19933)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
    at android.view.View.draw(View.java:20208)
    at android.view.View.updateDisplayListIfDirty(View.java:19080)
    at android.view.View.draw(View.java:19933)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
    at android.view.View.updateDisplayListIfDirty(View.java:19071)
    at android.view.View.draw(View.java:19933)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
    at android.view.View.updateDisplayListIfDirty(View.java:19071)
    at android.view.View.draw(View.java:19933)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
    at android.view.View.updateDisplayListIfDirty(View.java:19071)
    at android.view.View.draw(View.java:19933)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
    at android.view.View.updateDisplayListIfDirty(View.java:19071)
    at android.view.View.draw(View.java:19933)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4333)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112)
    at android.view.View.draw(View.java:20208)
    at com.android.internal.policy.DecorView.draw(DecorView.java:784)
    at android.view.View.updateDisplayListIfDirty(View.java:19080)
    at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:685)
    at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:691)
    at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:799)
    at android.view.ViewRootImpl.draw(ViewRootImpl.java:3259)
    at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3075)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2455)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1443)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7125)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:935)
    at android.view.Choreographer.doCallbacks(Choreographer.java:747)
    at android.view.Choreographer.doFrame(Choreographer.java:682)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:921)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6649)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:826)

推荐答案

它实际上告诉您原因:

仅允许INTERSECT和DIFFERENCE

only INTERSECT and DIFFERENCE are allowed

原因写为 此处 :

此方法在API级别26中已弃用.Region.Op值other 比INTERSECT和DIFFERENCE具有扩展剪辑的能力.这 画布剪辑API仅用于扩展剪辑 还原操作.这使视图父级可以将画布剪辑到 清楚地定义其子项的最大绘图区域.这 推荐的替代调用是clipRect(RectF)和 clipOutRect(RectF);从API级别开始,API级别为Build.VERSION_CODES.P 只有INTERSECT和DIFFERENCE是有效的Region.Op参数.

This method was deprecated in API level 26. Region.Op values other than INTERSECT and DIFFERENCE have the ability to expand the clip. The canvas clipping APIs are intended to only expand the clip as a result of a restore operation. This enables a view parent to clip a canvas to clearly define the maximal drawing area of its children. The recommended alternative calls are clipRect(RectF) and clipOutRect(RectF); As of API Level API level Build.VERSION_CODES.P only INTERSECT and DIFFERENCE are valid Region.Op parameters.

因此,您要么必须使用较低的targetSdk版本(否则就不应该使用,因为Google会迫使您在年底之前至少使用26个版本),或者通过在画布中使用裁剪功能来修复它一种不同的方式.

So you either have to use lower targetSdk version (which you shouldn't, because Google will force you to use at least 26 it by the end of the year), or you fix it by using your clipping via the canvas in a different way.

我已经在 此处 上询问了一个替代方法.

I've asked a question about it here, of what's the alternative.

这篇关于自定义键盘不适用于Android P Beta的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆