Skip to content

libsentry.so not exported when building Unity as a Library (Unity 2022.3.62, Sentry 2.0.7) #2339

@pb-mohit-singh

Description

@pb-mohit-singh

Environment

Hi team,

I’m integrating Unity as a Library into my React Native Android project and using Sentry Unity SDK 2.0.7 with Unity 2022.3.62.

When I build a standalone Unity APK, the native libsentry.so files are correctly included inside the APK under:

lib/arm64-v8a/libsentry.so
lib/armeabi-v7a/libsentry.so

However, when I export Unity as a Library (AAR) and then build the final Android APK from the host project, the .so files are not included in the exported Unity library. This leads to runtime errors because the native Sentry library cannot be found.

Error:
Sentry: Error loading the list of debug images: System.DllNotFoundException: Unable to load DLL 'sentry'.
Tried the load the following dynamic libraries: Unable to load dynamic library 'sentry' because of 'Failed to open the requested dynamic library (0x06000000) 
dlerror() = dlopen failed: library "sentry" not found
  at Sentry.Unity.NativeUtils.C.sentry_get_modules_list () [0x00000]
  at Sentry.Unity.NativeUtils.C.LoadDebugImages () [0x00000]
  at System.Lazy`1[T].CreateValue () [0x00000]
  at Sentry.Unity.UnityIl2CppEventExceptionProcessor+<>c.<.cctor>b__12_0 () [0x00000]

Steps to Reproduce

1.Create a Unity project with Unity 2022.3.62.
2.Install Sentry Unity SDK 2.0.7.
3.Export Unity as a Library (.aar).
4.Integrate Unity Library into a native Android project.
5.Build and run the APK from Android Studio.
6.Observe that libsentry.so is missing, causing DllNotFoundException.

Expected Result

When exporting Unity as a Library, libsentry.so should be included in the generated .aar (similar to standalone APK builds), so that downstream Android projects don’t need to manually copy .so files into jniLibs.

Workaround

Currently, the only workaround is to manually copy libsentry.so files into:

app/src/main/jniLibs/arm64-v8a/
app/src/main/jniLibs/armeabi-v7a/

Environment

Unity: 2022.3.62 LTS
Sentry Unity SDK: 2.0.7
Platform: Android (Unity as a Library)
Build system: Gradle / Android Studio

Actual Result

When Unity is exported as a Library, the generated .aar does not contain libsentry.so.
As a result, the final APK built from the host Android project fails at runtime with:

System.DllNotFoundException: Unable to load DLL 'sentry'
dlopen failed: library "sentry" not found

Any logs or screenshots

Sentry: Error loading the list of debug images: System.DllNotFoundException: Unable to load DLL 'sentry'. Tried the load the following dynamic libraries: Unable to load dynamic library 'sentry' because of 'Failed to open the requested dynamic library (0x06000000) dlerror() = dlopen failed: library "sentry" not found
  at Sentry.Unity.NativeUtils.C.sentry_get_modules_list () [0x00000] in <00000000000000000000000000000000>:0 
  at Sentry.Unity.NativeUtils.C.LoadDebugImages () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Lazy`1[T].ViaFactory (System.Threading.LazyThreadSafetyMode mode) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Lazy`1[T].ExecutionAndPublication (System.LazyHelper executionAndPublication, System.Boolean useDefaultConstructor) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Lazy`1[T].CreateValue () [0x00000] in <00000000000000000000000000000000>:0 
  at Sentry.Unity.UnityIl2CppEventExceptionProcessor+<>c.<.cctor>b__12_0 () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Lazy`1[T].ViaFactory (System.Threading.LazyThreadSafetyMode mode) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Lazy`1[T].ExecutionAndPublication (System.LazyHelper executionAndPublication, System.Boolean useDefaultConstructor) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Lazy`1[T].CreateValue () [0x00000] in <00000000000000000000000000000000>:0 
  at Sentry.Unity.UnityIl2CppEventExceptionProcessor.FindDebugImageContainingAddress (System.Int64 instructionAddress) [0x00000] in <00000000000000000000000000000000>:0 
  at Sentry.Unity.UnityIl2CppEventExceptionProcessor.Process (System.Exception incomingException, Sentry.SentryEvent sentryEvent) [0x00000] in <00000000000000000000000000000000>:0 
  at Sentry.SentryClient.DoSendEvent (Sentry.SentryEvent event, Sentry.SentryHint hint, Sentry.Scope scope) [0x00000] in <00000000000000000000000000000000>:0 
  at Sentry.SentryClient.CaptureEvent (Sentry.SentryEvent event, Sentry.Scope scope, Sentry.SentryHint hint) [0x00000] in <00000000000000000000000000000000>:0 
  at Sentry.Internal.Hub.CaptureEvent (Sentry.SentryEvent evt, Sentry.Scope scope, Sentry.SentryHint hint) [0x00000] in <00000000000000000000000000000000>:0 
  at Sentry.SentryClientExtensions.CaptureException (Sentry.ISentryClient client, System.Exception ex) [0x00000] in <00000000000000000000000000000000>:0 
  at Sentry.Unity.Integrations.UnityLogHandlerIntegration.CaptureException (System.Exception exception, UnityEngine.Object context) [0x00000] in <00000000000000000000000000000000>:0 
  at Sentry.Unity.Integrations.UnityLogHandlerIntegration.LogException (System.Exception exception, UnityEngine.Object context) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.Debug.CallOverridenDebugHandler (System.Exception exception, UnityEngine.Object obj) [0x00000] in <00000000000000000000000000000000>:0 
  at PimDeWitte.UnityMainThreadDispatcher.UnityMainThreadDispatcher.Update () [0x00000] in <00000000000000000000000000000000>:0 
Sentry.Unity.Integrations.UnityLogHandlerIntegration:LogFormat(LogType, Object, String, Object[])
Sentry.Unity.NativeUtils.C:LoadDebugImages()
System.Lazy`1:CreateValue()
Sentry.Unity.<>c:<.cctor>b__12_0()
System.Lazy`1:CreateValue()
Sentry.Unity.UnityIl2CppEventExceptionProcessor:FindDebugImageContainingAddress(Int64)
Sentry.Unity.UnityIl2CppEventExceptionProcessor:Process(Exception, SentryEvent)
Sentry.SentryClient:DoSendEvent(SentryEvent, SentryHint, Scope)
Sentry.SentryClient:CaptureEvent(SentryEvent, Scope, SentryHint)
Sentry.Internal.Hub:CaptureEvent(SentryEvent, Scope, SentryHint)
Sentry.SentryClientExtensions:CaptureException(ISentryClient, Exception)
Sentry.Unity.Integrations.UnityLogHandlerIntegration:CaptureException(Exception, Object)
Sentry.Unity.Integrations.UnityLogHandlerIntegration:LogException(Exception, Object)
UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)
PimDeWitte.UnityMainThreadDispatcher.UnityMainThreadDispatcher:Update()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    No status

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions