Reputation: 11
I'm following this tutorial https://www.sitepoint.com/face-detection-in-android-with-google-play-services/ step by step.
Nevertheless, i'm facing some errors that i can't solve through stackoverflow.
the piece of code with troubles is the following:
super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
InputStream stream = getResources().openRawResource(R.raw.image01);
Bitmap bitmap = BitmapFactory.decodeStream(stream);
FaceDetector detector = new FaceDetector.Builder(getApplicationContext())
.setTrackingEnabled(false)
.build();
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//create a frame from the bitmap and run face detection on the frame
Frame frame = new Frame.Builder().setBitmap(bitmap).build();
SparseArray<Face> faces = detector.detect(frame);
TextView faceCountView = (TextView) findViewById(R.id.face_count);
faceCountView.setText(faces.size() + "faces detected");
detector.release();
and i'm getting those errors:
C:\Users\XXX\FaceDetectionDemo\app\src\main\java\com\example\XXX\facedetectiondemo\MainActivity.java Error:(40, 49) error: cannot find symbol class Builder Error:(51, 21) error: cannot find symbol class Face Error:(51, 43) error: cannot find symbol method detect(Frame) Error:(56, 17) error: cannot find symbol method release() Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
build.gradle has the correct dependencies
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.android.gms:play-services:8.1.0'
}
I tried with this entry cannot find symbol class "Builder"enter image description hereuilder?rq=1 but it doesn't work
[SDK TOOLS INSTALLED]
Upvotes: 1
Views: 5654
Reputation: 21
I had the same problem. Then I found this solution; it worked for me: you must delete the library.
Change this:
import android.media.FaceDetector;
to:
import com.google.android.gms.vision.face.FaceDetector;
Upvotes: 2