3

I'm trying to write my own camera app using the newer camera2 API. At this point I'm just trying to get the app to start with the camera showing up on a fixed 640x480 SurfaceView in the emulated Nexus 5.

Here's the error I'm getting from Logcat, as well as the relevant code: http://pastebin.com/sESf6C1p

I honestly have no clue what's wrong here, even after lots of debugging and reading the API documentation over and over. I've found some evidence that I should add a delay before calling createCaptureSession (Android Camera - app passed NULL surface) which I tried with SystemClock.sleep(1000), but to no avail. Not sure what to make of "eglCreateContext: EGL error: 0x3005" either.

I'm calling createCaptureSession in the surfaceChanged callback which is run after surfaceCreated, so the surface should be all set up shouldn't it? I don't understand why the SDK is passing around a null surface internally.

Any tips appreciated!

Community
  • 1
  • 1
Chetic
  • 127
  • 2
  • 9
  • 2
    "app passed NULL surface" is a debug-level message. The failure is an IllegalStateException from `android.hardware.camera2.legacy.SurfaceTextureRenderer.configureEGLContext`, which seems to be having trouble with the EGL context. Are you running with GPU emulation enabled? Have you tried your app on a real device? – fadden Mar 13 '15 at 15:16

1 Answers1

2

Turns out the error is because the emulated Nexus 5 doesn't have GL support. It worked fine on my Nexus 9 (the debug log printed "Camera configured!").

The emulator doesn't start for me without the "Use Host GPU" setting enabled, but that's a different story. I'll just run on real hardware.

Chetic
  • 127
  • 2
  • 9