Skip to content

.NET MAUI SampleRate option crashes on Android. #2997

@v-antunovic

Description

@v-antunovic

Package

Sentry.Maui

.NET Flavor

.NET Core

.NET Version

8.0.0

OS

Android

SDK Version

3.41.3

Self-Hosted Sentry Version

No response

Steps to Reproduce

  1. Create .NET MAUI Blazor Hybrid applicaiton using Visual Studio template.
  2. Add Sentry.Maui nuget package
  3. Add .UseSentry() option (code below)
  4. Run app on Android emulator
var builder = MauiApp.CreateBuilder();
builder
    .UseMauiApp<App>()
    .ConfigureFonts(fonts =>
    {
        fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
    }
    ).UseSentry(o =>
    {
        o.Dsn = "xxx";
        o.SampleRate = (float?)1.0;
    });
    // ...
    return builder.Build(); // Exception is thrown on this line

Expected Result

Sentry should work.

Actual Result

InvalidCastException is thrown on line

return builder.Build();

System.InvalidCastException: 'Specified cast is not valid.'

Base exception stack trace is

   at Sentry.SentrySdk.<>c__DisplayClass6_0.<InitSentryAndroidSdk>b__0(SentryAndroidOptions o)
   at Sentry.Android.Callbacks.OptionsConfigurationCallback.Configure(Object optionsObject)
   at Sentry.JavaSdk.Sentry.IOptionsConfigurationInvoker.n_Configure_Lio_sentry_SentryOptions_(IntPtr jnienv, IntPtr native__this, IntPtr native_p0)
   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V(_JniMarshal_PPL_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 125

SentryError

When runing on windows machine everything works fine, on android emulator it crashes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Done

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions