Short answer:
Disable hardware acceleration and everything will be fine!
Long answer:
I had the same problem. In my View View code, I have a Canvas.drawVertices () call that looks like this:
canvas.drawVertices(Canvas.VertexMode.TRIANGLES, mTriVerts.length, mTriVerts, 0, null, 0, mTriangleColors, 0, null, 0, 0, mTriPaint);
This works exactly the same as expected on many devices, but on my 4.x test device the triangle I'm trying to draw just disappears and there are no traces in the logarithm to indicate why.
After I didnβt find a solution with SO, I started digging around and accidentally found the following shocking solution: a bunch of standard material will not work if hardware acceleration is enabled, including any call to Canvas.drawVertices() , and hardware acceleration is turned on by default for all supporting it devices for Android 4.x and later.
The problem and a good solution are outlined in the official Android docs . To summarize it here, simply put this on the line preceding your unsupported calls:
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
This is at the View level, and, unfortunately, it is impossible to re-enable hardware acceleration in a view that has been set to program mode at the moment, but reading documents that, in his opinion, could be an option in the future. If you feel that your code needs hardware acceleration, just avoid using calls or collect incompatible code in the view yourself and project it to see that you are actually typing something, doing it this way.
IMPORTANT CHANGE:
The setLayerType() call is only supported at the level of Android 11 and later, which means that you must wrap your calls to this function in a version check for it to work in earlier versions, for example:
if (android.os.Build.VERSION.SDK_INT >= 11) { setLayerType(View.LAYER_TYPE_SOFTWARE, null); }
NOW, you must be tuned!
PS: I hope this answer reaches you on time!