Я создал библиотечный модуль android для реализации логики c с использованием библиотеки Firebase MLKit Vision и с примером проекта работает локально. Но когда я пытаюсь опубликовать sh локальную зависимость maven или экспортировать .aar, у меня появляется следующая ошибка:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/ml/vision/face/FirebaseVisionFaceDetectorOptions$Builder;
at com.face.recognition.library.detection.FaceDetectionProcessor.<init>(FaceDetectionProcessor.kt:27)
at com.face.recognition.library.LegacyLivePreviewActivity.createCameraSource(LegacyLivePreviewActivity.kt:78)
at com.face.recognition.library.LegacyLivePreviewActivity.onCreate(LegacyLivePreviewActivity.kt:47)
at android.app.Activity.performCreate(Activity.java:7825)
at android.app.Activity.performCreate(Activity.java:7814)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1306)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.ml.vision.face.FirebaseVisionFaceDetectorOptions$Builder" on path: DexPathList[[zip file "/data/app/sample-DiQs8qInpjzgW0pepALP4A==/base.apk"],nativeLibraryDirectories=[/data/app/sample-DiQs8qInpjzgW0pepALP4A==/lib/arm64, /data/app/sample-DiQs8qInpjzgW0pepALP4A==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
Это мой build.gradle для библиотеки android, которая содержит Firebase MLKit Зависимость:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'maven-publish'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
def artifactId = 'com.example'
def groupId = 'library'
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
dexOptions {
javaMaxHeapSize "2g"
}
buildTypes {
release {
multiDexKeepFile file('multidex-config.txt')
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug{
multiDexKeepFile file('multidex-config.txt')
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.appcompat:appcompat:${app_compat_version}"
//api(name:'firebase-ml-vision-24.0.3', ext:'aar')
//api(name:'firebase-ml-vision-face-model-20.0.1', ext:'aar')
api "com.google.firebase:firebase-ml-vision:${firebase_ml_vision_version}"
api "com.google.firebase:firebase-ml-vision-face-model:${firebase_face_model_version}"
// api "com.google.android.gms:play-services-base:17.0.0"
testImplementation "junit:junit:${junit_version}"
androidTestImplementation "androidx.test.ext:junit:${android_test_version}"
androidTestImplementation "androidx.test.espresso:espresso-core:${expresso_core_version}"
}
project.afterEvaluate {
publishing {
publications {
library(MavenPublication) {
setGroupId groupId
setArtifactId artifactId
version android.defaultConfig.versionName
artifact bundleReleaseAar
}
}
}
}
Это версии:
ext {
app_compat_version = "1.1.0"
firebase_core_version = "16.0.9"
firebase_ml_vision_version = "24.0.3"
firebase_face_model_version = "20.0.1"
junit_version = "4.12"
android_test_version = "1.1.1"
expresso_core_version = "3.2.0"
ktx_core_version = "1.1.0"
}