We have developed a library that among other things, uses Android Mobile Vision API in order to detect user's face. The following problem occurs only on Lenovo Tab E7 and Billow X703.
private void createCameraSource() {
Context context = getApplicationContext();
FaceDetector detector = new FaceDetector.Builder(context)
.setProminentFaceOnly(true)
.setTrackingEnabled(true)
.setClassificationType(com.google.android.gms.vision.face.FaceDetector.ALL_CLASSIFICATIONS)
.setMode(com.google.android.gms.vision.face.FaceDetector.ACCURATE_MODE)
.setMinFaceSize(minFaceSize)
.build(); // <--- HERE IS THE EXCEPTION
detector.setProcessor(
new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory())
.build());
if (!detector.isOperational()) {
// Note: The first time that an app using face API is installed on a device, GMS will
// download a native library to the device in order to do detection. Usually this
// completes before the app is run for the first time. But if that download has not yet
// completed, then the above call will not detect any faces.
//
// isOperational() can be used to check if the required native library is currently
// available. The detector will automatically become operational once the library
// download completes on device.
Log.w(TAG, "Face detector dependencies are not yet available.");
// Check for low storage. If there is low storage, the native library will not be
// downloaded, so detection will not become operational.
IntentFilter lowstorageFilter = new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW);
boolean hasLowStorage = registerReceiver(null, lowstorageFilter) != null;
if (hasLowStorage) {
Toast.makeText(this, R.string.low_storage_error, Toast.LENGTH_LONG).show();
Log.w(TAG, getString(R.string.low_storage_error));
}
}
mCameraSource = new CameraSource.Builder(context, detector)
.setFacing(CameraSource.CAMERA_FACING_FRONT)
.setRequestedFps(fps)
.build();
}
When it is about to build the face detector an exception occurs (See below). Following, the code checks if the detector isOperational()
, which returns false. The exception shown is:
2019-05-22 16:09:48.128 27557-27557/com.xxx.xxx.xxx W/DynamiteModule: Local module descriptor class for com.google.android.gms.vision.dynamite.face not found.
2019-05-22 16:09:48.134 25402-25415/? W/ProviderHelper: Unknown dynamite feature vision.dynamite.face
2019-05-22 16:09:48.140 27557-27557/com.xxx.xxx.xxx I/DynamiteModule: Considering local module com.google.android.gms.vision.dynamite.face:0 and remote module com.google.android.gms.vision.dynamite.face:0
2019-05-22 16:09:48.140 27557-27557/com.xxx.xxx.xxx D/FaceNativeHandle: Cannot load feature, fall back to load whole module.
2019-05-22 16:09:48.142 27557-27557/com.xxx.xxx.xxx W/DynamiteModule: Local module descriptor class for com.google.android.gms.vision.dynamite not found.
2019-05-22 16:09:48.144 25402-25415/? W/ProviderHelper: Unknown dynamite feature vision.dynamite
2019-05-22 16:09:48.149 27557-27557/com.xxx.xxx.xxx I/DynamiteModule: Considering local module com.google.android.gms.vision.dynamite:0 and remote module com.google.android.gms.vision.dynamite:0
2019-05-22 16:09:48.154 27557-27557/com.xxx.xxx.xxx E/FaceNativeHandle: Error Loading module
com.google.android.gms.dynamite.DynamiteModule$LoadingException: No acceptable module found. Local version is 0 and remote version is 0.
at com.google.android.gms.dynamite.DynamiteModule.load(Unknown Source:8)
at com.google.android.gms.internal.vision.zzm.zzq(Unknown Source:28)
at com.google.android.gms.vision.face.internal.client.zzc.<init>(Unknown Source:3)
at com.google.android.gms.vision.face.FaceDetector$Builder.build(Unknown Source:40)
at com.xxx.xxx.xxx.activities.Activity1.createCameraSource(Activity1.java:128)
at com.xxx.xxx.xxx.activities.Activity1.onCreate(Activity1.java:111)
at android.app.Activity.performCreate(Activity.java:7023)
at android.app.Activity.performCreate(Activity.java:7014)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2758)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2883)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1613)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857)
2019-05-22 16:09:48.154 27557-27557/com.xxx.xxx.xxx W/FaceNativeHandle: Native handle not yet available. Reverting to no-op handle.
Once the application is installed on the phone, a line in the AndroidManifest.xml
should inform the mobile app to download the appropriate face detection lib for the particular device. However, this seems to happen only when the device is reset to the factory settings and the first time the app is installed. If I re-install the app through Android Studio for example, then the app is not able to find the particular module.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxx.xxx.xxx"
android:installLocation="auto">
<uses-permission
android:name="android.permission.INTERNET"
android:required="true" />
<uses-permission-sdk-23
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:required="true" />
<uses-permission-sdk-23
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:required="true" />
<uses-permission
android:name="android.permission.CAMERA"
android:required="true" />
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.front" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application
android:allowBackup="true"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true">
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.gms.vision.DEPENDENCIES"
android:value="face" />
<activity
android:name=".activities.Activity1"
android:screenOrientation="portrait" />
<activity
android:name=".activities.Activity2"
android:screenOrientation="portrait" />
<activity
android:name=".activities.Activity3"
android:screenOrientation="portrait" />
</application>
</manifest>
We are using Google Play Services 17.0.2
implementation 'com.google.android.gms:play-services-vision:17.0.2'
We have checked and tried the following:
- Clearing the data and cache of the Google Play services/Google Play Store/mobile app.
- Free space. The device has 8GB of memory out of which 3.82GB is free space.
- Storage permissions. The app has storage permissions and
android:installLocation="auto"
- Internet connection. The device has active WiFi internet connection and the appropriate internet permissions.
The library works perfectly fine on other devices in any situation. On the aforementioned devices it works only the first time the app is deployed after factory reset.