Skip to content

Android 15: UnsatisfiedLinkError: dlopen failed: empty/missing DT_HASH/DT_GNU_HASH #26027

@H4dr1en

Description

@H4dr1en

System Information

OpenCV version: 4.10.0
OpenCV source: org.opencv:opencv
Android Studio Version: Android Studio Koala | 2024.1.1 Patch 2
Android Studio Emulator: Android API 35 (16KB Page Size Google APIs)

Detailed description

Similar to realm/realm-java#7894

I was testing our application with an Android emulator with Android 15 with support for 16KB page sizes, and it crashed with the below stacktrace when trying to init OpenCV:

2024-08-14 15:39:39.362  5743-5743  OpenCV/StaticHelper     com.example.testopencv               D  First attempt to load libs
2024-08-14 15:39:39.362  5743-5743  OpenCV/StaticHelper     com.example.testopencv               D  Trying to load library opencv_java4
2024-08-14 15:39:39.363  5743-5743  nativeloader            com.example.testopencv               D  Load /data/app/~~UDDPcaZygQcTBXL5vZYi_Q==/com.example.testopencv-_GQnH6g4tXR0x9T9boJcCQ==/lib/arm64/libopencv_java4.so using ns clns-7 from class loader (caller=/data/app/~~UDDPcaZygQcTBXL5vZYi_Q==/com.example.testopencv-_GQnH6g4tXR0x9T9boJcCQ==/base.apk): dlopen failed: empty/missing DT_HASH/DT_GNU_HASH in "/data/app/~~UDDPcaZygQcTBXL5vZYi_Q==/com.example.testopencv-_GQnH6g4tXR0x9T9boJcCQ==/lib/arm64/libopencv_java4.so" (new hash type from the future?)
2024-08-14 15:39:39.364  5743-5743  OpenCV/StaticHelper     com.example.testopencv               D  Cannot load library "opencv_java4"
2024-08-14 15:39:39.364  5743-5743  System.err              com.example.testopencv               W  java.lang.UnsatisfiedLinkError: dlopen failed: empty/missing DT_HASH/DT_GNU_HASH in "/data/app/~~UDDPcaZygQcTBXL5vZYi_Q==/com.example.testopencv-_GQnH6g4tXR0x9T9boJcCQ==/lib/arm64/libopencv_java4.so" (new hash type from the future?)
2024-08-14 15:39:39.364  5743-5743  System.err              com.example.testopencv               W  	at java.lang.Runtime.loadLibrary0(Runtime.java:1081)
2024-08-14 15:39:39.365  5743-5743  System.err              com.example.testopencv               W  	at java.lang.Runtime.loadLibrary0(Runtime.java:1003)
2024-08-14 15:39:39.365  5743-5743  System.err              com.example.testopencv               W  	at java.lang.System.loadLibrary(System.java:1765)
2024-08-14 15:39:39.365  5743-5743  System.err              com.example.testopencv               W  	at org.opencv.android.StaticHelper.loadLibrary(StaticHelper.java:44)
2024-08-14 15:39:39.365  5743-5743  System.err              com.example.testopencv               W  	at org.opencv.android.StaticHelper.initOpenCV(StaticHelper.java:19)
2024-08-14 15:39:39.365  5743-5743  System.err              com.example.testopencv               W  	at org.opencv.android.OpenCVLoader.initDebug(OpenCVLoader.java:22)
2024-08-14 15:39:39.365  5743-5743  System.err              com.example.testopencv               W  	at com.example.testopencv.MainActivity.onCreate(MainActivity.kt:16)
2024-08-14 15:39:39.366  5743-5743  System.err              com.example.testopencv               W  	at android.app.Activity.performCreate(Activity.java:9002)
2024-08-14 15:39:39.366  5743-5743  System.err              com.example.testopencv               W  	at android.app.Activity.performCreate(Activity.java:8980)
2024-08-14 15:39:39.366  5743-5743  System.err              com.example.testopencv               W  	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1526)
2024-08-14 15:39:39.366  5743-5743  System.err              com.example.testopencv               W  	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4030)
2024-08-14 15:39:39.366  5743-5743  System.err              com.example.testopencv               W  	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4235)
2024-08-14 15:39:39.366  5743-5743  System.err              com.example.testopencv               W  	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:112)
2024-08-14 15:39:39.366  5743-5743  System.err              com.example.testopencv               W  	at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:174)
2024-08-14 15:39:39.366  5743-5743  System.err              com.example.testopencv               W  	at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:109)
2024-08-14 15:39:39.366  5743-5743  System.err              com.example.testopencv               W  	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:81)
2024-08-14 15:39:39.366  5743-5743  System.err              com.example.testopencv               W  	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2636)
2024-08-14 15:39:39.366  5743-5743  System.err              com.example.testopencv               W  	at android.os.Handler.dispatchMessage(Handler.java:107)
2024-08-14 15:39:39.366  5743-5743  System.err              com.example.testopencv               W  	at android.os.Looper.loopOnce(Looper.java:232)
2024-08-14 15:39:39.366  5743-5743  System.err              com.example.testopencv               W  	at android.os.Looper.loop(Looper.java:317)
2024-08-14 15:39:39.366  5743-5743  System.err              com.example.testopencv               W  	at android.app.ActivityThread.main(ActivityThread.java:8705)
2024-08-14 15:39:39.366  5743-5743  System.err              com.example.testopencv               W  	at java.lang.reflect.Method.invoke(Native Method)
2024-08-14 15:39:39.366  5743-5743  System.err              com.example.testopencv               W  	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
2024-08-14 15:39:39.366  5743-5743  System.err              com.example.testopencv               W  	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
2024-08-14 15:39:39.366  5743-5743  OpenCV/StaticHelper     com.example.testopencv               D  First attempt to load libs fails
2024-08-14 15:39:39.390  5743-5743  HWUI                    com.example.testopencv               W  Unknown dataspace 0
2024-08-14 15:39:39.411  5743-5774  EGL_emulation           com.example.testopencv               I  Opening libGLESv1_CM_emulation.so
2024-08-14 15:39:39.412  5743-5774  EGL_emulation           com.example.testopencv               I  Opening libGLESv2_emulation.so
2024-08-14 15:39:39.418  5743-5774  HWUI                    com.example.testopencv               W  Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
2024-08-14 15:39:39.419  5743-5774  HWUI                    com.example.testopencv               W  Failed to initialize 101010-2 format, error = EGL_SUCCESS
2024-08-14 15:39:39.445  5743-5774  Gralloc4                com.example.testopencv               I  mapper 4.x is not supported
2024-08-14 15:39:39.560  5743-5748  mple.testopencv         com.example.testopencv               I  Compiler allocated 4206KB to compile void android.widget.TextView.<init>(android.content.Context, android.util.AttributeSet, int, int)
2024-08-14 15:39:39.635  5743-5748  mple.testopencv         com.example.testopencv               I  Compiler allocated 5250KB to compile void android.view.ViewRootImpl.performTraversals()

Looks like the openCV library needs to be recompiled as documented here

Steps to reproduce

You can reproduce the issue by:

  1. Opening this small android project TestOpenCV.zip with Android studio
  2. Setting up an Android 15 emulator with support for 16kb page size
  3. Runing the toy app in the emulator

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions