gpt4 book ai didi

java - 错误 : cannot find symbol class Builder

转载 作者:行者123 更新时间:2023-11-29 19:45:58 27 4
gpt4 key购买 nike

我正在学习本教程 https://www.sitepoint.com/face-detection-in-android-with-google-play-services/一步步。

不过,我遇到了一些无法通过 stackoverflow 解决的错误。

有问题的代码如下:

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();

我遇到了这些错误:

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 有正确的依赖

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'
}

我尝试使用此条目 cannot find symbol class "Builder" enter image description here uilder?rq=1 但它不起作用

[已安装 SDK 工具]

最佳答案

我遇到了同样的问题。然后我找到了这个解决方案;它对我有用:您必须删除该库。

改变这个:

import android.media.FaceDetector;

到:

import com.google.android.gms.vision.face.FaceDetector; 

关于java - 错误 : cannot find symbol class Builder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37710007/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com