Camera.open() returns null
For those who's testing an app on Android 6.0+, make sure that you have implemented Runtime Permission. Because simple permission in your AndroidManifest file is not enough.
I solved this issue by following below steps.
Open the "AVD Manager" and select the virtual device you are using
Click on the "Edit" button
In the "Hardware" section, select "New" and add "Configures camera facing back" and click Ok.
In the dropdown next to the entry, select "webcam0" or the one corresponding to the camera you want to use
Stop the AVD and restart again.
Figured it out,
You need to call Camera.open(0)
.
THIS IS ONLY VALID AND WORKING ON THE NEXUS 7 device, as it only has one camera, so is only useful if targeting that device only.