尝试启动人脸检测时访问 ByteBuffer 时出错

Error accessing ByteBuffer when trying to start face detection

我正在创建人脸检测应用程序。当我尝试启动人脸检测时,出现以下错误:

E/NativeFaceDetectorImpl: Native face detection failed
E/NativeFaceDetectorImpl: java.lang.RuntimeException: Error accessing ByteBuffer.

这是我的部分代码:

 Context context = getApplicationContext();
    FaceDetector detector = new FaceDetector.Builder(context)
            .setClassificationType(FaceDetector.ALL_CLASSIFICATIONS)
            .setMode(FaceDetector.ACCURATE_MODE)
            .build();

    detector.setProcessor(
            new MultiProcessor.Builder<>(new FaceTrackerFactory())
                    .build());

    if (!detector.isOperational()) {
        Log.w(TAG, "Face detector dependencies are not yet available.");
    }

    mCameraSource = new CameraSource.Builder(context, detector)
            .setFacing(CameraSource.CAMERA_FACING_BACK)
            .setRequestedFps(30.0f)
            .build();

当我执行 mCameraSource.start() 时显示错误,即使这样做时没有检测到错误并且应用程序没有崩溃,它只是在控制台上重复显示该错误。

所以我能够找出问题所在。我正在尝试使用来自 Google Play Services 8.1.0 版的 Mobile Vision API 为 Android API 19 进行编译。这是在我的 build.gradle 和 它没有工作:

dependencies {
    compile 'com.google.android.gms:play-services-vision:8.1.0'
}

android {
    compileSdkVersion 19
}

我切换到 Google Play Services 的 7.8 版,现在 工作正常

dependencies {
    compile 'com.google.android.gms:play-services-vision:7.8.+'
}

android {
    compileSdkVersion 19
}

另请注意,我有另一个类似的项目正在为 Android API 23 编译,对于那个版本,Google Play Services 8.1 正在运行.

dependencies {
    compile 'com.google.android.gms:play-services-vision:8.1.0'
}

android {
    compileSdkVersion 23
}