Google ML Kit Dependency

Anyline’s scanning runs on the Anyline scanning engine and does not use Google ML Kit.

Google ML Kit is an optional dependency, needed only for two features. Both are disabled by default:

  • Face detection, used on Universal ID / MRZ only when faceDetectionEnabled is set to true on universalIdConfig or mrzConfig. It uses the ML Kit face-detection module.

  • Native barcode detection, an optional legacy camera-feed barcode detector enabled through the nativeBarcodeScanningFormats option. It uses the ML Kit barcode-scanning module. Anyline’s own barcode scanning does not use it.

The Anyline Android SDK does not bundle Google ML Kit. If you use one of the two features above, add the matching dependency to your app yourself (see below). Apps that use neither ship with no Google ML Kit, and need no code or manifest changes.

Enabling a feature without its module does not disable the feature silently. It fails at ScanView.init(…​). See If the dependency is missing.

Do you need Google ML Kit?

Feature Needs ML Kit Dependency to add

Anyline barcode scanning (Barcode plugin)

No

None (runs on the Anyline engine)

OCR, Meter, ID / MRZ, License Plate, Tire, VIN, Container, Document

No

None (faceDetectionEnabled stays false, the default)

Face detection on Universal ID / MRZ (faceDetectionEnabled = true)

Yes

com.google.mlkit:face-detection:16.1.7

Native barcode detection (nativeBarcodeScanningFormats)

Yes

com.google.mlkit:barcode-scanning:17.3.0

Add Google ML Kit (only if you need it)

Add the ML Kit module(s) for the feature(s) you use to your app-level build.gradle:

dependencies {
    implementation 'io.anyline:anylinesdk:56.3.0'

    // Add only the module(s) for the features you use:
    implementation 'com.google.mlkit:face-detection:16.1.7'    // for faceDetectionEnabled
    implementation 'com.google.mlkit:barcode-scanning:17.3.0'  // for nativeBarcodeScanningFormats
}

Once present, ML Kit initializes itself. The SDK also initializes it in code, on demand, when the feature runs. No further setup is required.

If the dependency is missing

If you enable faceDetectionEnabled or nativeBarcodeScanningFormats without adding the corresponding ML Kit module, the SDK fails fast. The check runs during ScanView.init(…​), while the configuration is being read and before any scanning starts.

The failure is reported as a ScanViewConfigRunValidationException.MlKitModuleMissing, with one subtype per module, FaceDetection and NativeBarcode, so you can tell the two apart without inspecting the message. ScanView.init(…​) wraps it in a RuntimeException, so read it from the cause:

try {
    scanView.init(scanViewConfigJson)
} catch (e: RuntimeException) {
    when (val cause = e.cause) {
        is ScanViewConfigRunValidationException.MlKitModuleMissing.FaceDetection ->
            // add com.google.mlkit:face-detection, or set faceDetectionEnabled to false
        is ScanViewConfigRunValidationException.MlKitModuleMissing.NativeBarcode ->
            // add com.google.mlkit:barcode-scanning, or remove nativeBarcodeScanningFormats
        else -> throw e
    }
}

Catch ScanViewConfigRunValidationException.MlKitModuleMissing instead if either module being absent should be handled the same way. Every one of these exceptions carries a message naming the missing module and how to resolve it.

To check a configuration up front, before building a scan view at all, use ScanViewConfigHolder.validateJsonObject. It reports the same failure as a result instead of an exception. Its exception property is typed Exception, because it also carries JSON schema failures, so test for the ML Kit case explicitly:

val result = ScanViewConfigHolder.validateJsonObject(context, scanViewConfigJson)
if (result is ScanViewConfigHolder.ScanViewJsonValidationResult.ValidationFailed) {
    if (result.exception is ScanViewConfigRunValidationException.MlKitModuleMissing) {
        // a required Google ML Kit module is missing
    } else {
        // the configuration does not match the JSON schema
    }
}

validateJsonObject takes an optional validateForRun parameter, true by default. Pass validateForRun = false to validate a configuration only against the JSON schema. This is useful when checking a configuration that is meant to run on a different build, for example in an authoring or tooling context. Configurations validated that way can still fail later, on the build that actually runs them.

Google’s data collection

Google ML Kit is Google’s software, not Anyline’s. When you add it to your app, it runs under Google’s ML Kit terms and may send its own diagnostic and usage data to Google. That traffic comes from the ML Kit libraries running in your app. It does not pass through the Anyline SDK, and Anyline neither controls it nor receives any of it.

Accepting Google’s terms is therefore a matter between your app and Google. If your app carries privacy notice, consent or data processing obligations, Google ML Kit falls under your app’s, not Anyline’s.

If you do not add it, no Google ML Kit code ships in your app and none of this applies. The next section shows how to confirm that.

Verify a build without Google ML Kit

For privacy-sensitive deployments that use neither feature, confirm no ML Kit is present:

  • Inspect the merged manifest (app/build/intermediates/merged_manifest/…​/AndroidManifest.xml). There should be no com.google.mlkit.common.internal.MlKitInitProvider.

  • Check the APK with the Android Studio APK Analyzer. There should be no com.google.mlkit.* classes.

  • Run your ID / MRZ scan (with faceDetectionEnabled = false) and confirm it completes with no crash and no ML Kit or Google Play Services network traffic.