mlkit icon indicating copy to clipboard operation
mlkit copied to clipboard

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

Open vajjasivateja opened this issue 2 years ago • 17 comments

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)

vajjasivateja avatar Feb 27 '23 01:02 vajjasivateja

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.

jackqdyulei avatar Apr 27 '23 23:04 jackqdyulei

Hi. I have faced with the same problem.

Снимок экрана 2023-05-02 в 14 43 39 Снимок экрана 2023-05-02 в 14 44 04

pavel163 avatar May 02 '23 10:05 pavel163

Hi, @jackqdyulei Do you have any updates?

pavel163 avatar Jul 25 '23 12:07 pavel163

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

pavel163 avatar Jul 25 '23 12:07 pavel163

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!

jackqdyulei avatar Jul 25 '23 19:07 jackqdyulei

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)

pavel163 avatar Jul 26 '23 15:07 pavel163

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

  • 40% - Android 12
  • 34% - Android 11
  • 22% - Android 13
  • 4% - Android 10

Devices

  • 27% - Xiaomi
    • 7% - Redmi Note 12 Pro 5G
    • 5% - POCO M3
    • 4% - REDMI NOTE 9 Pro
    • 3% - Redmi Note 11 Pro 5G
    • 2% - Redmi Note 11 Pro Max
    • 2% - Poco X3 NFC
    • 2% - Redmi 9A
    • 2% - Redmi 10 2022
  • 20% - Samsung
    • 4% - Galaxy S23
    • 4% - Galaxy Z Fold2 5G
    • 3% - Galaxy A80
    • 3% - Galaxy A13
    • 2% - Galaxy S23 Ultra
    • 2% - Galaxy S23 Ultra 5G
    • 2% - Galaxy A04
  • 13% - Honor
    • 4% - Honor X6
    • 4% - Honor X9a 5G
    • 3% - Honor 50 Lite
    • 2% - Honor X8 a
  • 7% - Transsion - Unisoc
    • 4% Canon 20 Pro
    • 3% Tecno POP 7
  • 33% - Other (8)
    • 7% - OPPO
    • 7% - Transsion - Mediatek
    • 4% - Motorola
    • 4% - Transsion
    • 4% - Transsion

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)

haytham-c01 avatar Aug 10 '23 07:08 haytham-c01

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!

jackqdyulei avatar Aug 10 '23 16:08 jackqdyulei

@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.

haytham-c01 avatar Aug 30 '23 13:08 haytham-c01

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
  • 64%Xiaomi -19%Redmi Note 9 Pro -18%Redmi Note 11S -9%Redmi Note 10 -18%Other (2)

  • %27 Samsung -9%Galaxy A51 -9%Galaxy A13 -9%Galaxy A12

  • Honor 50

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){ ...

b-basoglu avatar Sep 07 '23 20:09 b-basoglu

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?

AradiPatrik avatar Dec 21 '23 03:12 AradiPatrik

Having the same error as well. On oneplus device.

adonese avatar Feb 05 '24 12:02 adonese

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 avatar Feb 16 '24 01:02 slice-tanyaa

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?

slice-tanyaa avatar Feb 16 '24 10:02 slice-tanyaa

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

dqh147258 avatar Feb 18 '24 03:02 dqh147258

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

JustAClamber avatar Mar 04 '24 05:03 JustAClamber

-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.

b-basoglu avatar Jun 29 '24 20:06 b-basoglu