【问题标题】:error: cannot find symbol class Builder错误:找不到符号类生成器
【发布时间】:2016-10-09 03:57:24
【问题描述】:

我正在逐步学习本教程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 错误:(40、49)错误:找不到符号类生成器错误:(51、21) 错误:找不到符号类人脸错误:(51、43)错误:找不到 符号方法检测(帧)错误:(56,17)错误:找不到符号 方法释放()错误:任务执行失败 ':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 hereuilder?rq=1 但它不起作用

[SDK 工具已安装]

【问题讨论】:

  • 更新你的 google play 服务库...依赖项 { compile 'com.google.android.gms:play-services:9.0.1' }
  • 但是我得到另一个错误。即使实现了库。错误:(26, 13) 无法解决:com.google.android.gms:play-services:9.0.1 安装存储库并同步项目
    在文件中显示
    显示在项目结构对话框中
  • 当我尝试“更新”时(因为它已经更新)。我得到:正在加载 SDK 信息...忽略未知包过滤器“extra-google-m2repository”警告:包过滤器已删除所有包。没有什么要安装的。请考虑在没有包过滤器的情况下再次尝试更新。

标签: java android face-detection


【解决方案1】:

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

改变这个:

import android.media.FaceDetector;

到:

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

【讨论】:

    猜你喜欢
    • 2022-06-21
    • 2020-01-10
    • 1970-01-01
    • 2020-05-03
    • 2019-01-13
    • 2018-05-30
    • 2015-01-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多