mediapipe
mediapipe copied to clipboard
Mobile app crashes in AndroidStudio with java.lang.UnsatisfiedLinkError: dlopen failed: library "libmediapipe_tasks_text_jni.so" not found
OS Platform and Distribution
Linux Ubuntu 22.04
Compiler version
No response
Programming Language and version
Kotlin JVM target 1.8
Installed using virtualenv? pip? Conda?(if python)
No response
MediaPipe version
v0.10.11
Bazel version
No response
XCode and Tulsi versions (if iOS)
No response
Android SDK and NDK versions (if android)
API 34
Android AAR (if android)
None
OpenCV version (if running on desktop)
No response
Describe the problem
Building and executing the text_classification example Android app in AndroidStudio's emulator crashes at startup
Complete Logs
2024-04-29 15:53:39.584 8190-8190 AndroidRuntime pid-8190 E FATAL EXCEPTION: main
Process: com.google.mediapipe.examples.textclassifier, PID: 8190
java.lang.UnsatisfiedLinkError: dlopen failed: library "libmediapipe_tasks_text_jni.so" not found
at java.lang.Runtime.loadLibrary0(Runtime.java:1082)
at java.lang.Runtime.loadLibrary0(Runtime.java:1003)
at java.lang.System.loadLibrary(System.java:1661)
at com.google.mediapipe.tasks.text.textclassifier.TextClassifier.<clinit>(TextClassifier.java:98)
at com.google.mediapipe.examples.textclassifier.TextClassifierHelper.initClassifier(TextClassifierHelper.kt:47)
at com.google.mediapipe.examples.textclassifier.TextClassifierHelper.<init>(TextClassifierHelper.kt:35)
at com.google.mediapipe.examples.textclassifier.TextClassifierHelper.<init>(TextClassifierHelper.kt:26)
at com.google.mediapipe.examples.textclassifier.MainActivity.onCreate(MainActivity.kt:66)
at android.app.Activity.performCreate(Activity.java:8595)
at android.app.Activity.performCreate(Activity.java:8573)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3764)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3922)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8177)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Hi @quentingrimaudpaloit,
We advise against running our GenAI task APIs, such as LLM inference and Image Generator, on an emulator. Our team has confirmed that emulators may not smoothly handle our APIs and it will lead to crash. We recommend running them on a real physical device instead. On real device, If you encounter any issues, please let us know.
Thank you!!
Thanks for your answer :) I'm OK to test these features only on a real device, but does it imply that developers who code a mobile app which contains these features have to completely give up on using an emulator even for testing all other features of their app which do not use mediapipe? Emulators provide quick iteration which is a central part of a good developer experience. What is the recommended way (design patterns etc) to develop a mobile app which uses mediapipe and still be able to use the emulator to manually test parts of the app which do not use mediapipe?
Hi @quentingrimaudpaloit,
We can understand that while emulators offer clear advantages, our GenTaskAPI currently requires access to physical hardware that emulators often lack. We have confirmed with the team that emulator compatibility is not on our roadmap for the foreseeable future.
Thank you!!!
This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.
This issue was closed due to lack of activity after being marked stale for past 7 days.
I found out while I was working on this issue, that I can circumvent the crash of the app at application startup in Android Studio emulator (Running Devices tab), by using feature flags: I have created a global boolean variable, and in the rest of the code, functions which require mediapipe are called only if this variable is true, a fallback is executed otherwise. So I can safely manually test all other features of my app.
I confirm, i'm facing the same issue when testing the MediaPipe sample app from MediaPipe android sample repo. Running on Android emulator with "UpsideDownCake - Android 14" in Android studio, i get the error .
Android Studio Koala
MediPipe v0.10.14
Kotlin v1.9
At least the documentation should point out that testing on emulators will not work.
java.lang.UnsatisfiedLinkError: dlopen failed: library "libmediapipe_tasks_text_jni.so" not found
at java.lang.Runtime.loadLibrary0(Runtime.java:1082)
at java.lang.Runtime.loadLibrary0(Runtime.java:1003)
at java.lang.System.loadLibrary(System.java:1661)
at com.google.mediapipe.tasks.text.languagedetector.LanguageDetector.<clinit>(LanguageDetector.java:83)
at com.newmedia.mediapipetext.domain.LanguageDetectorHelper.initDetector(LanguageDetectorHelper.kt:46)
at com.newmedia.mediapipetext.domain.LanguageDetectorHelper.<init>(LanguageDetectorHelper.kt:34)
Yeah agreed, there should definitely be a note on the website.