Cannot resolve symbol n method

2.5k views Asked by At

i'm creating android app which use camera. I have problems with some methods. For example:

camera = Camera.open(cameraID); - cannot resolve method 'open(int)'
camera.takePicture(null, null, this); - cannot resolve method 'takePicture'

i've got similar problems [ camera.release(); etc. ] I was trying to import android.hardware.camera2; but it does not help

any ideas to resolve ?

2

There are 2 answers

0
Eddy Talvala On

You're using the older android.hardware.Camera API, so make sure you have imported it with

import android.hardware.Camera;

Even though it is deprecated, it continues to work just fine, and is necessary for using the camera on pre-Lollipop (API21) devices.

0
Moritz On

Camera2 api is only available since Android Lollipop (api 21). Make sure you have set you targetSdkVersion in your build.gradle file to at least 21.