Troubleshooting

Installation Issues

Package Manager - Cannot perform upm operation: Unable to add package

If you encounter the following error:

Copied
[Package Manager Window] Unable to add package [https://github.com/getsentry/unity.git#0.9.1 ]:
  Error when executing git command. fatal: invalid refspec '0.9.1 '

Confirm the URL doesn't have a trailing whitespace or spaces in the URL. The Unity Package Manager will fail to find the package if whitespace is appended.

URL link with an additional space

Package Manager - 'HEAD': cannot update ref 'refs/heads/master'

Some Unity versions, such as 2019.4.24f1 and 2020.3.2f1, have a bug on UPM and fail to install with the error 'HEAD': cannot update ref 'refs/heads/master'. Unity has resolved this issue on newer releases. Learn more by checking the Unity Issue Tracker.

PrecompiledAssemblyException: Multiple precompiled assemblies with the same name

This issue was resolved in the release 0.7.0 of the Sentry SDK for Unity. If you're still encountering this issue on a version later than 0.7.0, please let us know with an issue report.

Editor Issues

Sentry.Unity.Editor.iOS - System.Reflection.ReflectionTypeLoadException

The Sentry.Unity.Editor.iOS.dll is responsible for adding native support to your iOS builds. For that, it relies on editor functionality that Unity provides in the form of their iOS module. If you don't have the iOS module installed and, for example, Assembly.GetTypes() gets called, this leads to a ReflectionTypeLoadException. To resolve this, you can install the iOS module using the Unity Hub or, if you don't intend to build for iOS, you can embed the Sentry SDK package and safely remove the Sentry.Unity.Editor.iOS.dll.

Build Issues

Incompatibility between Sentry SDK and Unity 2022.1

We are aware of an incompatibility between the SDK and Unity 2022.1 when building with IL2CPP, that is related to Il2CppFullySharedGenericAny. We are tracking the (issue)[https://github.com/getsentry/sentry-unity/issues/691] on Github and reported it with (Unity)[https://fogbugz.unity3d.com/default.asp?1419859_qmt0m8hc0mpc1mc5].

Disabling the Sentry SDK for selected platforms

By adding the snippet below to an Editor directory inside your Unity project, you can set up the ability to automatically disable the Sentry SDK for any targeted platform.

Copied
using Sentry.Unity;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;

public class PreBuildProcessor : IPreprocessBuildWithReport
{
    public int callbackOrder => 0;

    public void OnPreprocessBuild(BuildReport report)
    {
        if (report.summary.platform is BuildTarget.Android)
        {
            var sentryOptions =
                AssetDatabase.LoadAssetAtPath<ScriptableSentryUnityOptions>("Assets/Resources/Sentry/SentryOptions.asset");
            sentryOptions.Enabled = false;
            EditorUtility.SetDirty(sentryOptions);
        }
    }
}

Build input file cannot be found: '**/Libraries/io.sentry.unity/Plugins/iOS/SentryNativeBridge.m'

You can resolve this issue by creating a clean build or chosing "Replace" when prompted. Alternatively, you can remove the unused SentryNativeBridge.mfrom the UnityFramework Target > Compile Sources in the project settings. Instead of relying on Unity to copy the SentryNativeBridge.m over to the generated Xcode project, starting with 0.12.0, the SDK copies it manually to **/Libraries/io.sentry.unity/SentryNativeBridge.m.

Failed to locate the Sentry package

This happens if you've copied some of the SDK files directly to the Assets folder. You can resolve this issue by installing the SDK with UPM.

Runtime issues

Library not loaded: @rpath/Sentry.framework/Sentry

If you encounter the following error:

Copied
2021-10-29 15:21:40.011452-0400 MyApp[2180:186329] Error loading /var/containers/Bundle/Application/88CC4619-7C5D-4BB1-9F4B-5AAD7EC4BF9C/MyApp.app/Frameworks/UnityFramework.framework/UnityFramework:  dlopen(/var/containers/Bundle/Application/88CC4619-7C5D-4BB1-9F4B-5AAD7EC4BF9C/MyApp.app/Frameworks/UnityFramework.framework/UnityFramework, 265): Library not loaded: @rpath/Sentry.framework/Sentry
  Referenced from: /private/var/containers/Bundle/Application/88CC4619-7C5D-4BB1-9F4B-5AAD7EC4BF9C/MyApp.app/Frameworks/UnityFramework.framework/UnityFramework
  Reason: image not found

This can happen if you've copied some of the SDK files directly to the Assets folder and the Sentry.Unity.Editor.iOS.dll which runs when you build an iOS player wasn't able to copy the Sentry.framework to the final app. Enabling debug mode in the Sentry editor window would display more information in the Unity console.

You can resolve this issue by installing the SDK with UPM.

Events

Unhandled Exceptions - Debug.LogException

Currenty, it is not possible for the SDK to distinguish between the user calling Debug.LogException and the SDK capturing an unhandled exception. To capture an exception and mark it as handled you can call SentrySDK.CaptureException instead.

Universal Windows Platform - Events Not Sent

In order to send events to Sentry, you will need to activate the InternetClient Capability in your Player Settings.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").