I'm trying to implement face detection in my Kotlin + Firebase app. I followed the ML Kit tutorial available in the ML site, but I keep getting an error related to the implementation in:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/TelemetryLoggingOptions;
at com.google.android.gms.internal.mlkit_vision_face.zzli.<init>(com.google.android.gms:play-services-mlkit-face-detection@@16.1.5:2)
at com.google.android.gms.internal.mlkit_vision_face.zzli.zza(com.google.android.gms:play-services-mlkit-face-detection@@16.1.5:1)
at com.google.mlkit.vision.face.internal.zzh.<init>(com.google.android.gms:play-services-mlkit-face-detection@@16.1.5:4)
at com.google.mlkit.vision.face.internal.zze.create(com.google.android.gms:play-services-mlkit-face-detection@@16.1.5:9)
at com.google.mlkit.common.sdkinternal.LazyInstanceMap.get(com.google.mlkit:common@@17.1.1:3)
at com.google.mlkit.vision.face.internal.zzd.zzb(com.google.android.gms:play-services-mlkit-face-detection@@16.1.5:2)
at com.google.mlkit.vision.face.FaceDetection.getClient(com.google.android.gms:play-services-mlkit-face-detection@@16.1.5:3)
I tried to use both ways
implementation 'com.google.mlkit:face-detection:16.0.6'
implementation 'com.google.android.gms:play-services-mlkit-face-detection:16.1.5' with the meta-data added in manifest:
<meta-data
android:name="com.google.mlkit.vision.DEPENDENCIES"
android:value="face" />
In both ways, I get the same error. Does anyone knows how to solve it?
This is the gradle:
apply plugin: "com.android.dynamic-feature"
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply from: '../version_control.gradle'
android {
buildFeatures {
viewBinding true
}
compileSdkVersion 29
buildToolsVersion "29.0.3"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
packagingOptions {
exclude 'META-INF/library_release.kotlin_module'
}
sourceSets {
main {
/* https://wiki.vectorlabs.cloud/x/1IgVAg */
res.srcDirs = [
'src/main/res/home',
'src/main/res/qrcode',
'src/main/res/gamification',
'src/main/res/cafDetails',
'src/main/res/registration.hub',
'src/main/res/registration.email',
'src/main/res/registration.vehicle',
'src/main/res/deliveryFlow',
]
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation project(":base")
api project(":delivery_types") /*Para usar a activity de Informacoes*/
implementation 'androidx.core:core-ktx:1.3.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.1'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.googlecode.libphonenumber:libphonenumber:8.8.3'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
kapt 'com.github.bumptech.glide:glide:4.11.0'
kapt 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.github.qoqa:glide-svg:2.0.4'
androidTestImplementation 'androidx.annotation:annotation:1.1.0'
androidTestImplementation project(':base')
// FirebaseUI for Firebase Realtime Database
implementation 'com.firebaseui:firebase-ui-firestore:7.0.0'
//SMS Retrieval API
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation 'org.apache.commons:commons-lang3:3.11'
implementation 'org.greenrobot:eventbus:3.2.0'
//facial recognition
implementation 'com.google.android.gms:play-services-mlkit-face-detection:16.1.5'
}
kapt {
correctErrorTypes true
}