I\'m trying to incorporate the Google Play Services 7.8 Face API in my app, but every time I try to detect faces it gives me the error:
FaceDetectorHa
The first time that face detection functionality is run on a device, it is necessary to download a face detection library to the device. The "Native face detector not yet available." message indicates that the library has not yet been downloaded.
It's recommended that the mobile vision dependencies are added to the AndroidManifest.xml. This will proactively request the library download when the app is installed. See this note in the docs:
Add the Vision Dependency to your Android Manifest
Adding the vision functionality dependency to your project's AndroidManifest.xml will indicate to the installer that it should download the dependency on app install time. Although this is not strictly required, it can make the user experience better when initially running your app. For example, adding the following to AndroidManifest.xml (in the application section) will indicate that both the barcode and face detection dependencies should be downloaded at app install time:
Valid vision dependency values are: barcode or face
However, even if this is supplied, in some cases the dependencies required to run the detectors may be downloaded on demand when your app is run for the first time rather than at install time. See isOperational() and detectorIsOperational() for more information on checking the dependency download status in your app.
As indicated above, your app can check for this with the isOperational() method:
https://developers.google.com/android/reference/com/google/android/gms/vision/face/FaceDetector.html#isOperational()
The detector will try to download the libraries while your app is running, and will automatically become operational once the libraries have been obtained.
But in some cases the download might not succeed (e.g., if the device does not have sufficient free storage space, or if the device isn't connected to the network). The first thing to try would be freeing up more storage space.
Calling release()
The following warning from the log indicates a different issue:
W/FaceDetector(25536): FaceDetector was not released with FaceDetector.release()
Your app should call the release() method on the detector (or camera source) when it no longer needs it. This will free up resources. Although this isn't related to the download issue, it is good to do in general. For example, if the detector was created in an activity, it's good to release that resource in onDestroy():
protected void onDestroy() {
super.onDestroy();
mCameraSource.release();
}