GLES20Canvas.clipPath中的UnsupportedOperationException,禁用硬件加速

我在我的应用程序中启用了硬件加速function,但是由于笔画大小写等问题,我禁用了该function。

现在,我在Google Play崩溃错误控制台中获取这个堆栈跟踪:

java.lang.UnsupportedOperationException at android.view.GLES20Canvas.clipPath(GLES20Canvas.java:287) at com.myapp.MyCustomView.onDraw(SourceFile:288) at android.view.View.draw(View.java:9310) at android.view.View.getDisplayList(View.java:8773) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2298) ... at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:609) at android.view.ViewRoot.draw(ViewRoot.java:1634) at android.view.ViewRoot.performTraversals(ViewRoot.java:1450) at android.view.ViewRoot.handleMessage(ViewRoot.java:2094) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:132) at android.app.ActivityThread.main(ActivityThread.java:4123) ... 

我在AndroidManifest.xml中指定了android:hardwareAccelerated="true" 。 但我特别禁用了我的自定义视图的构造函数中的硬件加速:

  public MyCustomView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // ... code omitted // disable acceleration because Paint.setStrokeCap(Cap.ROUND) is not working otherwise Compatibility.disableHardwareAcceleration(this); } 

与兼容性是这样的:

 public class Compatibility { // View.setLayerType() was introduced in Honeycomb private static Method setLayerTypeMethod = getMethod(View.class, "setLayerType", int.class, Paint.class); private static Method getMethod(Class<?> clazz, String name, Class<?>... parameterTypes) { try { return clazz.getMethod(name, parameterTypes); } catch (NoSuchMethodException e) { return null; } } private Compatibility() { } public static void disableHardwareAcceleration(View view) { try { if (setLayerTypeMethod != null) { int layerType = 1; // View.LAYER_TYPE_SOFTWARE setLayerTypeMethod.invoke(view, layerType, null); } } catch (Exception ignored) { } } } 

不幸的是,崩溃错误控制台不显示有关Android操作系统版本或设备的信息。

任何想法可能会发生什么?

Solutions Collecting From Web of "GLES20Canvas.clipPath中的UnsupportedOperationException,禁用硬件加速"