googlesamples / mlkit

A collection of sample apps to demonstrate how to use Google's ML Kit APIs on Android and iOS
Apache License 2.0
3.52k stars 2.92k forks source link

java.lang.UnsatisfiedLinkError: dlopen failed "----lib/arm64/libface_detector_v2_jni.so" has bad ELF magic: 00000000 #632

Open vajjasivateja opened 1 year ago

vajjasivateja commented 1 year ago

In my firebase crashlytics recently I am seeing repeated bug which is below

Screenshot 2023-02-27 at 9 28 27 AM

Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app/~~ic2W0xno23mcxTN9NrOZqw==/com.xxxxxxx.xxxxx.app-lGoYxe43v8GESjnUcqYZeQ==/lib/arm64/libface_detector_v2_jni.so" has bad ELF magic: 00000000 at java.lang.Runtime.loadLibrary0(Runtime.java:1087) at java.lang.Runtime.loadLibrary0(Runtime.java:1008) at java.lang.System.loadLibrary(System.java:1664) at com.google.mlkit.vision.face.bundled.internal.ThickFaceDetectorCreator.(com.google.mlkit:face-detection@@16.1.5:1) at java.lang.Class.newInstance(Class.java) at com.google.android.gms.dynamite.DynamiteModule.instantiate(com.google.android.gms:play-services-basement@@18.0.0:2) at com.google.mlkit.vision.face.internal.zza.zze(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:2) at com.google.mlkit.vision.face.internal.zza.zzg(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:1) at com.google.mlkit.vision.face.internal.zza.zzf(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:22) at com.google.mlkit.vision.face.internal.zza.zzd(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:2) at com.google.mlkit.vision.face.internal.zzh.load(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:1) at com.google.mlkit.common.sdkinternal.ModelResource.zza(com.google.mlkit:common@@18.1.0:4) at com.google.mlkit.common.sdkinternal.zzl.run(com.google.mlkit:common@@18.1.0:10) at com.google.mlkit.common.sdkinternal.zzp.run(com.google.mlkit:common@@18.1.0:2) at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zze(com.google.mlkit:common@@18.1.0:4) at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zzc(com.google.mlkit:common@@18.1.0:1) at com.google.mlkit.common.sdkinternal.zzi.run(com.google.mlkit:common@@18.1.0:2) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zzd(com.google.mlkit:common@@18.1.0:2) at com.google.mlkit.common.sdkinternal.zzj.run(com.google.mlkit:common@@18.1.0:2) at java.lang.Thread.run(Thread.java:923)

jackqdyulei commented 1 year ago

Thanks for your report. For those repeated bugreports, are they all coming from OPPO and Android 11? If not, please help to list out the affected devices & API level.

pavel163 commented 1 year ago

Hi. I have faced with the same problem.

Снимок экрана 2023-05-02 в 14 43 39 Снимок экрана 2023-05-02 в 14 44 04
pavel163 commented 1 year ago

Hi, @jackqdyulei Do you have any updates?

pavel163 commented 1 year ago

Hi, @vajjasivateja Have you found how to fix it?

jackqdyulei commented 1 year ago

Hi Pavel, sorry for the late reply. Could you help to provide the failing device list(e.g. Oppo xxx) with OS version. I will try to repro from my side. Thanks!

pavel163 commented 1 year ago

Hi @jackqdyulei. Below is the list of devices

Vivo: Y16(android 12), Y02s (android 12), Y02t (android 13) Oppo: A17k (android 12), A57 (android 12) Samsung: Galaxy A14 (android 13) Huawei: PPA-LX2 (android 10), MED-LX9 (android 10) Transsion - Uniso: Tecno POP 5 LTE (android 11)

haytham-c01 commented 1 year ago

I am getting a similar crash to @pavel163 reported by Firebase Crashlytics.

General

Occurrence: the crash occurred 55 times for 33 users within 90 days.

Dependency: com.google.mlkit:face-detection:16.1.5

Android OS

Devices

Exceptions

Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: library "/data/app/~~6-LXVzl5kHBKBV1QjfYGSA==/com.placeholder.package-3VfFUnRvMZ3TfRsXcJ2wvg==/split_config.arm64_v8a.apk!/lib/arm64-v8a/libface_detector_v2_jni.so" not found
       at java.lang.Runtime.loadLibrary0(Runtime.java:1077)
       at java.lang.Runtime.loadLibrary0(Runtime.java:998)
       at java.lang.System.loadLibrary(System.java:1661)
       at com.google.mlkit.vision.face.bundled.internal.ThickFaceDetectorCreator.<clinit>(com.google.mlkit:face-detection@@16.1.5:1)
       at java.lang.Class.newInstance(Class.java)
       at com.google.android.gms.dynamite.DynamiteModule.instantiate(com.google.android.gms:play-services-basement@@18.1.0:2)
       at com.google.mlkit.vision.face.internal.zza.zze(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:2)
       at com.google.mlkit.vision.face.internal.zza.zzg(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:1)
       at com.google.mlkit.vision.face.internal.zza.zzf(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:5)
       at com.google.mlkit.vision.face.internal.zza.zzd(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:2)
       at com.google.mlkit.vision.face.internal.zzh.load(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:1)
       at com.google.mlkit.common.sdkinternal.ModelResource.zza(com.google.mlkit:common@@18.1.0:4)
       at com.google.mlkit.common.sdkinternal.zzl.run(com.google.mlkit:common@@18.1.0:10)
       at com.google.mlkit.common.sdkinternal.zzp.run(com.google.mlkit:common@@18.1.0:2)
       at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zze(com.google.mlkit:common@@18.1.0:4)
       at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zzc(com.google.mlkit:common@@18.1.0:1)
       at com.google.mlkit.common.sdkinternal.zzi.run(com.google.mlkit:common@@18.1.0:2)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
       at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zzd(com.google.mlkit:common@@18.1.0:2)
       at com.google.mlkit.common.sdkinternal.zzj.run(com.google.mlkit:common@@18.1.0:2)
       at java.lang.Thread.run(Thread.java:1012)
Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: library "/data/app/com.placeholder.package-Mg7-zjnjOvvvwrGahPDYeQ==/split_config.armeabi_v7a.apk!/lib/armeabi-v7a/libface_detector_v2_jni.so" not found
       at java.lang.Runtime.loadLibrary0(Runtime.java:1071)
       at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
       at java.lang.System.loadLibrary(System.java:1667)
       at com.google.mlkit.vision.face.bundled.internal.ThickFaceDetectorCreator.<clinit>(com.google.mlkit:face-detection@@16.1.5:1)
       at java.lang.Class.newInstance(Class.java)
       at com.google.android.gms.dynamite.DynamiteModule.instantiate(com.google.android.gms:play-services-basement@@18.1.0:2)
       at com.google.mlkit.vision.face.internal.zza.zze(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:2)
       at com.google.mlkit.vision.face.internal.zza.zzg(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:1)
       at com.google.mlkit.vision.face.internal.zza.zzf(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:5)
       at com.google.mlkit.vision.face.internal.zza.zzd(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:2)
       at com.google.mlkit.vision.face.internal.zzh.load(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:1)
       at com.google.mlkit.common.sdkinternal.ModelResource.zza(com.google.mlkit:common@@18.1.0:4)
       at com.google.mlkit.common.sdkinternal.zzl.run(com.google.mlkit:common@@18.1.0:10)
       at com.google.mlkit.common.sdkinternal.zzp.run(com.google.mlkit:common@@18.1.0:2)
       at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zze(com.google.mlkit:common@@18.1.0:4)
       at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zzc(com.google.mlkit:common@@18.1.0:1)
       at com.google.mlkit.common.sdkinternal.zzi.run(com.google.mlkit:common@@18.1.0:2)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zzd(com.google.mlkit:common@@18.1.0:2)
       at com.google.mlkit.common.sdkinternal.zzj.run(com.google.mlkit:common@@18.1.0:2)
       at java.lang.Thread.run(Thread.java:919)
jackqdyulei commented 1 year ago

Hi haytham-c01, to understand the issue better, could you help to

1) Check your apk to make sure the native library is truly bundled. I believe so however want to sanity check 2) Check whether this is a constant failing on specific device(e.g. Galaxy S23)

Thanks!

haytham-c01 commented 1 year ago

@jackqdyulei Sorry for the delay, I overlooked the email for your reply.

  1. I checked both the APK generated by the Android Studio build and the one installed on the device from the "device explorer" and both include the ".so" library.
  2. We tested it on one of the newly appearing devices (Xiaomi Poco F5) and the app didn't crash.
b-basoglu commented 1 year ago

I am following this issue nearly for 4 months now. Is there any update? I am facing the same issue.

Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: library "libface_detector_v2_jni.so" not found at java.lang.Runtime.loadLibrary0(Runtime.java:1077) at java.lang.Runtime.loadLibrary0(Runtime.java:998) at java.lang.System.loadLibrary(System.java:1661) at com.google.mlkit.vision.face.bundled.internal.ThickFaceDetectorCreator.(com.google.mlkit:face-detection@@16.1.5:1) at java.lang.Class.newInstance(Class.java) at com.google.android.gms.dynamite.DynamiteModule.instantiate(com.google.android.gms:play-services-basement@@18.1.0:2) at com.google.mlkit.vision.face.internal.zza.zze(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:2) at com.google.mlkit.vision.face.internal.zza.zzg(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:1) at com.google.mlkit.vision.face.internal.zza.zzf(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:22) at com.google.mlkit.vision.face.internal.zza.zzd(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:2) at com.google.mlkit.vision.face.internal.zzh.load(zzh.java:1) at com.google.mlkit.common.sdkinternal.ModelResource.zza(ModelResource.java:4) at com.google.mlkit.common.sdkinternal.zzl.run(com.google.mlkit:common@@18.1.0:38) at com.google.mlkit.common.sdkinternal.zzp.run(zzp.java:2) at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zze(MlKitThreadPool.java:4) at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zzc(MlKitThreadPool.java:1) at com.google.mlkit.common.sdkinternal.zzi.run(zzi.java:89) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zzd(MlKitThreadPool.java:2) at com.google.mlkit.common.sdkinternal.zzj.run(com.google.mlkit:common@@18.1.0:13) at java.lang.Thread.run(Thread.java:1012)

Screenshot 2023-09-07 at 21 34 24 Screenshot 2023-09-07 at 21 34 17

gradle-8.0 (8.0.2) - Compile sdk & Target sdk 33

I am generating bundle not apk.

    ndk {
        abiFilters "arm64-v8a", "armeabi-v7a"
    }

implementation "com.google.mlkit:face-detection:16.1.5"

Android Studio Android Studio Flamingo | 2022.2.1 Patch 2

Sniped code block

class FaceDetector {

private val options = FaceDetectorOptions.Builder()
    .setPerformanceMode(FaceDetectorOptions.PERFORMANCE_MODE_FAST)
    .setLandmarkMode(FaceDetectorOptions.LANDMARK_MODE_NONE)
    .setClassificationMode(FaceDetectorOptions.CLASSIFICATION_MODE_NONE)
    .setContourMode(FaceDetectorOptions.CONTOUR_MODE_NONE)
    .setMinFaceSize(0.15F)
    .build()

private val faceDetector: FaceDetector by lazy { FaceDetection.getClient(options) }

fun detectFace(image:Image){ ...
AradiPatrik commented 9 months ago

I am facing the same issue. Couldn't reproduce it with the devices available to me but I see the error in crashlytics and received a one star review because the face detection not working...

image

The .so is there in my aab.

Affected devices (so far): Pixel 6 Pro - Android 12 Nexus 5X - Android 8.1.0

Here is the stack trace:

Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: library "libface_detector_v2_jni.so" not found
       at java.lang.Runtime.loadLibrary0(Runtime.java:1077)
       at java.lang.Runtime.loadLibrary0(Runtime.java:998)
       at java.lang.System.loadLibrary(System.java:1656)
       at com.google.mlkit.vision.face.bundled.internal.ThickFaceDetectorCreator.<clinit>(com.google.mlkit:face-detection@@16.1.5:1)
       at java.lang.Class.newInstance(Class.java)
       at com.google.android.gms.dynamite.DynamiteModule.instantiate(com.google.android.gms:play-services-basement@@18.1.0:2)
       at com.google.mlkit.vision.face.internal.zza.zze(zza.java:2)
       at com.google.mlkit.vision.face.internal.zza.zzg(zza.java:1)
       at com.google.mlkit.vision.face.internal.zza.zzf(zza.java:5)
       at com.google.mlkit.vision.face.internal.zza.zzd(zza.java:2)
       at com.google.mlkit.vision.face.internal.zzh.load(com.google.android.gms:play-services-mlkit-face-detection@@17.0.1:1)
       at com.google.mlkit.common.sdkinternal.ModelResource.zza(ModelResource.java:4)
       at com.google.mlkit.common.sdkinternal.zzl.run(zzl.java:47)
       at com.google.mlkit.common.sdkinternal.zzp.run(zzp.java:2)
       at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zze(MlKitThreadPool.java:4)
       at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zzc(MlKitThreadPool.java:1)
       at com.google.mlkit.common.sdkinternal.zzi.run(zzi.java:42)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zzd(MlKitThreadPool.java:2)
       at com.google.mlkit.common.sdkinternal.zzj.run(zzj.java:17)
       at java.lang.Thread.run(Thread.java:920)

The weird thing is that I didn't touch the face detection code since half a year and this started happening for my latest release.

Any pointers on how to fix this issue?

adonese commented 8 months ago

Having the same error as well. On oneplus device.

slice-tanyaa commented 7 months ago

Any idea on how to fix this? Is it related to NDK. Happening mostly in Vivo devices. https://stackoverflow.com/questions/62612144/my-app-crashes-when-opening-on-an-android-device-app-keeps-stopping-error

slice-tanyaa commented 7 months ago

Below was missing in my code.

defaultConfig { ndk { abiFilters "arm64-v8a", "armeabi-v7a" } }

also android.useDeprecatedNdk=true was not set.

could this be the reason?

dqh147258 commented 7 months ago
android {
    bundle {
        abi {
            enableSplit = false
        }
    }
}

Can we use this config to disable the google play package split so that the libface_detector_v2_jni.so can be kept

JustAClamber commented 7 months ago

This method solved my problem and I hope it helps you. https://github.com/googlesamples/mlkit/issues/483#issuecomment-1899917791

b-basoglu commented 3 months ago
-keep class com.google.mlkit.** { *; }
-keep class com.google.android.gms.** { *; }

Add this two line to proguard-rules. This will not solve all problems related to this .so file. This will just help you to reduce crashes. I am observing crashes are reduced significantly after adding these two line into proguard-rules.

# Keep all native method names
-keepclasseswithmembernames class * {
    native <methods>;
}

Also when you add this to proguard-rules, it will reduce your UnsatisfiedLinkErrors.


I have comments on this issue above. Ignore my previous comments on this issue since MissingSplitsManagerFactory deprecated and its usage is completely removed. You will have following warning on your google play console if you are using MissingSplitsManagerFactory. 👎 :( But adding these to proguard-rules will solve most of your crashes related to this .so issue.

com.google.android.play:core has added this note for core:1.10.3: Update your Play Core Maven dependency to an Android 14 compatible version! Your current Play Core library is incompatible with targetSdkVersion 34 (Android 14), which introduces a backwards-incompatible change to broadcast receivers to improve user security. As a reminder, from August 31, Google Play requires all new app releases to target Android 14. Update to the latest Play Core library version dependency to avoid app crashes.