Android emulator not showing canvas drawing

Viewed 1246

I have an app that draws animations to the canvas using a SurfaceView subclass. After upgrading to Android Studio 3.0, I started having problems with running the app on the emulator. The app works fine on a real Android device, but the drawing commands are not showing up at all when I run it on the emulator. There are buttons on the activity that show up, but the canvas is just blank and white. I tried the debugging technique here and it all looks fine when I inspect the bitmap, but it just won't show up at all on the emulator. Any ideas on how to resolve this would be fantastic.

2 Answers

I was having a hard time making canvas work in my app, and then I eventually thought it may be the emulator. Hans is right, you can make the canvases show up by tweaking the emulator settings.

Here's the settings that works for me on macOS 10.13.6 (any other combination didn't work):

  • OpenGL ES renderer: Desktop native OpenGL
  • OpenGL ES API level: Comptability (OpenGL ES 1.1/2.0)

Note that these fields are in the "Advanced" tabs under Settings.

Also, make sure to restart the emulator after updating the settings.

Related