---
title: ".NET for Android"
description: "Learn about Sentry's .NET integration with .NET for Android"
url: https://docs.sentry.io/platforms/dotnet/guides/android/
---

# .NET for Android | Sentry for .NET for Android

Sentry supports [.NET for Android](https://learn.microsoft.com/dotnet/android/getting-started/installation/) directly from the [Sentry NuGet package](https://www.nuget.org/packages/Sentry).

## [Overview of the features](https://docs.sentry.io/platforms/dotnet/guides/android.md#overview-of-the-features)

* All the features of our main [.NET SDK](https://docs.sentry.io/platforms/dotnet.md), for your managed code

* Attach LogCat logs to events

* Java crash reporting for Android, leveraging our [Android SDK](https://docs.sentry.io/platforms/android.md) including:

  * [Capture Application Not Responding (ANR) errors](https://docs.sentry.io/platforms/android/configuration/app-not-respond.md) when the app is unresponsive
  * Automatically [attach screenshots to Java exceptions](https://docs.sentry.io/platforms/android/enriching-events/screenshots.md)
  * Automatic breadcrumbs for Activity lifecycle, App lifecycle, System and Network events and User Interactions
  * Automatic [Activity lifecycle tracing](https://docs.sentry.io/platforms/android/tracing/instrumentation/automatic-instrumentation.md#activity-instrumentation) and [User Interaction tracing](https://docs.sentry.io/platforms/android/performance/instrumentation/automatic-instrumentation.md#user-interaction-instrumentation)
  * Device Root checking

* Native crash reporting for Android, leveraging our [Android NDK](https://docs.sentry.io/platforms/android/configuration/using-ndk.md)

* Automatic session tracking and [release health](https://docs.sentry.io/product/releases.md)

* *Session Replay for Android* (currently experimental)

## [Install](https://docs.sentry.io/platforms/dotnet/guides/android.md#install)

Add the Sentry dependency to your .NET for Android application:

```shell
dotnet add package Sentry -v 6.3.1
```

## [Configure](https://docs.sentry.io/platforms/dotnet/guides/android.md#configure)

In your `MainActivity.cs` file, call `SentrySdk.Init` in the `OnCreate` event and include any options you would like to set. The `Dsn` is the only required parameter.

```csharp
[Activity(Label = "@string/app_name", MainLauncher = true)]
public class MainActivity : Activity
{
    protected override void OnCreate(Bundle? savedInstanceState)
    {
        SentrySdk.Init(options =>
        {
            options.Dsn = "___PUBLIC_DSN___";
            options.SendDefaultPii = true; // adds the user's IP address automatically
#if DEBUG
            // Log debug information about the Sentry SDK
            options.Debug = true;
#endif

            // Android specific .NET features are under the Android properties:
            options.Android.LogCatIntegration = LogCatIntegrationType.Errors; // Get logcat logs for both handled and unhandled errors; default is unhandled only
            options.Android.LogCatMaxLines = 1000; // Defaults to 1000

            // All the native Android SDK options are available below
            // https://docs.sentry.io/platforms/android/configuration/
            // Enable Native Android SDK ANR detection
            options.Native.AnrEnabled = true;

            // Session Replay is currently available via the ExperimentalOptions
            options.Native.ExperimentalOptions.SessionReplay.OnErrorSampleRate = 1.0;
            options.Native.ExperimentalOptions.SessionReplay.SessionSampleRate = 1.0;
            options.Native.ExperimentalOptions.SessionReplay.MaskAllImages = false;
            options.Native.ExperimentalOptions.SessionReplay.MaskAllText = false;

            options.SetBeforeSend(evt =>
            {
                if (evt.Exception?.Message.Contains("Something you don't care want logged?") ?? false)
                {
                    return null; // return null to filter out event
                }
                // or add additional data
                evt.SetTag("dotnet-Android-Native-Before", "Hello World");
                return evt;
            });
        });

        base.OnCreate(savedInstanceState);
    }
}
```

### [Options](https://docs.sentry.io/platforms/dotnet/guides/android.md#options)

The .NET for Android integration is part of [Sentry](https://docs.sentry.io/platforms/dotnet.md). Please refer to the documentation for that package for information about platform agnostic options.

Android specific options are described below.

### [LogCatIntegration](https://docs.sentry.io/platforms/dotnet/guides/android.md#logcatintegration)

Can be set to control whether when LogCat logs are attached to events. It can be set to one of the following values:

* `None`: The LogCat integration is disabled.
* `Unhandled`: LogCat logs are attached to events only when the event is unhandled.
* `Errors`: LogCat logs are attached to events with an exception.
* `All`: LogCat logs are attached to all events.

The default is `LogCatIntegrationType.None`

Use caution when enabling `LogCatIntegrationType.All`, as this may result in a lot of data being sent to Sentry and performance issues if the SDK generates a lot of events.

### [LogCatMaxLines](https://docs.sentry.io/platforms/dotnet/guides/android.md#logcatmaxlines)

The maximum number of lines to read from LogCat logs.

The default value is 1000.

## [Verify](https://docs.sentry.io/platforms/dotnet/guides/android.md#verify)

This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.

```csharp
try
{
    throw null;
}
catch (Exception ex)
{
    SentrySdk.CaptureException(ex);
}
```

## [Next Steps](https://docs.sentry.io/platforms/dotnet/guides/android.md#next-steps)

* Explore [practical guides](https://docs.sentry.io/guides.md) on what to monitor, log, track, and investigate after setup

## Other .NET Frameworks

- [.NET for iOS, macOS, and Mac Catalyst](https://docs.sentry.io/platforms/dotnet/guides/apple.md)
- [ASP.NET](https://docs.sentry.io/platforms/dotnet/guides/aspnet.md)
- [ASP.NET Core](https://docs.sentry.io/platforms/dotnet/guides/aspnetcore.md)
- [AWS Lambda](https://docs.sentry.io/platforms/dotnet/guides/aws-lambda.md)
- [Azure Functions](https://docs.sentry.io/platforms/dotnet/guides/azure-functions-worker.md)
- [Blazor WebAssembly](https://docs.sentry.io/platforms/dotnet/guides/blazor-webassembly.md)
- [Entity Framework](https://docs.sentry.io/platforms/dotnet/guides/entityframework.md)
- [Google Cloud Functions](https://docs.sentry.io/platforms/dotnet/guides/google-cloud-functions.md)
- [log4net](https://docs.sentry.io/platforms/dotnet/guides/log4net.md)
- [MAUI](https://docs.sentry.io/platforms/dotnet/guides/maui.md)
- [Microsoft.Extensions.Logging](https://docs.sentry.io/platforms/dotnet/guides/extensions-logging.md)
- [NLog](https://docs.sentry.io/platforms/dotnet/guides/nlog.md)
- [Serilog](https://docs.sentry.io/platforms/dotnet/guides/serilog.md)
- [Windows Forms](https://docs.sentry.io/platforms/dotnet/guides/winforms.md)
- [WinUI](https://docs.sentry.io/platforms/dotnet/guides/winui.md)
- [WPF](https://docs.sentry.io/platforms/dotnet/guides/wpf.md)
- [Xamarin](https://docs.sentry.io/platforms/dotnet/guides/xamarin.md)

## Topics

- [Capturing Errors](https://docs.sentry.io/platforms/dotnet/guides/android/usage.md)
- [Enriching Events](https://docs.sentry.io/platforms/dotnet/guides/android/enriching-events.md)
- [Extended Configuration](https://docs.sentry.io/platforms/dotnet/guides/android/configuration.md)
- [Logs](https://docs.sentry.io/platforms/dotnet/guides/android/logs.md)
- [Data Management](https://docs.sentry.io/platforms/dotnet/guides/android/data-management.md)
- [Tracing](https://docs.sentry.io/platforms/dotnet/guides/android/tracing.md)
- [Profiling](https://docs.sentry.io/platforms/dotnet/guides/android/profiling.md)
- [Security Policy Reporting](https://docs.sentry.io/platforms/dotnet/guides/android/security-policy-reporting.md)
- [Crons](https://docs.sentry.io/platforms/dotnet/guides/android/crons.md)
- [Migration Guide](https://docs.sentry.io/platforms/dotnet/guides/android/migration.md)
- [Troubleshooting](https://docs.sentry.io/platforms/dotnet/guides/android/troubleshooting.md)
- [User Feedback](https://docs.sentry.io/platforms/dotnet/guides/android/user-feedback.md)
- [Metrics](https://docs.sentry.io/platforms/dotnet/guides/android/metrics.md)
- [Unit Testing](https://docs.sentry.io/platforms/dotnet/guides/android/unit-testing.md)
- [Legacy SDK](https://docs.sentry.io/platforms/dotnet/guides/android/legacy-sdk.md)
