旧版本 Android 的模拟器可能出现调用 Canvas.clipPath() 导致 app 崩溃的现象。这是因为模拟器在过低的 API 级别下启用了 Canvas 的硬件加速1,在对应 API 级别下强制关闭硬件加速就好了。

E/AndroidRuntime: FATAL EXCEPTION: main
    java.lang.UnsupportedOperationException
        at android.view.GLES20Canvas.clipPath(GLES20Canvas.java:408)
If your application is affected by any of these missing features or limitations, you can turn off hardware acceleration for just the affected portion of your application by calling setLayerType(View.LAYER_TYPE_SOFTWARE, null). This way, you can still take advantage of hardware acceleration everywhere else. See Control hardware acceleration for more information on how to enable and disable hardware acceleration at different levels in your application.

参考资料

标签: Android

添加新评论