Azure-Samples / cognitive-services-speech-sdk

Sample code for the Microsoft Cognitive Services Speech SDK
MIT License
2.77k stars 1.82k forks source link

Android SpeechConfig.fromSubscription(subscriptionKey, region) java.lang.UnsatisfiedLinkError #2492

Open DonKamillo2905 opened 1 month ago

DonKamillo2905 commented 1 month ago

Describe the bug The Android app crashes with the error java.lang.UnsatisfiedLinkError: dlopen failed: library "libMicrosoft.CognitiveServices.Speech.java.bindings.so" not found when trying to load the native libraries for Microsoft Cognitive Services Speech SDK in an Android application. The issue occurs consistently on the first run after installation but does not occur on subsequent runs. Additionally, logs show a FileNotFoundException for the APK files.

The crash specifically happens when calling SpeechConfig.fromSubscription(subscriptionKey, region). Even when wrapping this call in a try-catch block, the application still crashes. I also tried manually loading the library using System.loadLibrary("Microsoft.CognitiveServices.Speech.core"). This throws an error, but the application does not close. Subsequent calls to this method do not cause an error.

The application works correctly when run directly from Android Studio, but the error occurs when running the signed and bundled version.

To Reproduce

Steps to reproduce the behavior:

Expected behavior

The native libraries should load without errors, and the application should initialize the SpeechConfig object without crashing.

Version of the Cognitive Services Speech SDK

Version 1.36.0

Platform, Operating System, and Programming Language

OS: Android Programming language: Kotlin

Additional context

The issue occurs on the first run after installation. Subsequent runs do not exhibit the issue. The problem occurs on multiple devices and is logged in Firebase Crashlytics.

The application configuration is: minSdk: 28 targetSdk: 34 compileSdkVersion: 34

jychoudh commented 1 month ago

I followed the steps that you mentioned. I could not reproduce this.

DonKamillo2905 commented 1 month ago

The error only occurs when I Generate Signed App Bundle in release mode. When I run app from Android Studio, everything works fine. Maybe code minification or resource shrinking removes something. Do I need to add anything special to ProGuard? I didn't see anything in the Sample code.

DonKamillo2905 commented 1 month ago

It seems that the exact same app built as APK works but built as Android App Bundle doesn't work. Is there any solution for this?

github-actions[bot] commented 3 weeks ago

This item has been open without activity for 19 days. Provide a comment on status and remove "update needed" label.

DonKamillo2905 commented 3 weeks ago

I noticed that the application works in an application that has only one module. With Multi-module app there is an error as I mentioned earlier.

github-actions[bot] commented 3 days ago

This item has been open without activity for 19 days. Provide a comment on status and remove "update needed" label.