.NET for Android

Raygun provides a seamless way to report unhandled exceptions in your .NET Android applications. By integrating Raygun Crash Reporting, you can gain insights into the issues affecting your users, allowing for quicker resolution and improved app performance.


Before proceeding, ensure you have:

  • A Raygun account and a valid API key.
  • A .NET 6+ project for .NET Android.

note: This page is for .NET Android native apps, if you are looking for .NET MAUI or .NET Xamarin please follow the corresponding links




  1. Install the Raygun4Net Provider: Ensure that your .NET project has the Raygun4Net provider installed. You can install the Raygun4Net.NetCore NuGet package via the Package Manager Console:

    dotnet add package Mindscape.Raygun4Net.NetCore
    
  2. Initialize Raygun in Your Android Application: In your main Android activity, initialize the RaygunClient with your application API key. This setup will automate the reporting of unhandled exceptions to Raygun.

    protected override void OnCreate(Bundle savedInstanceState)
    {
       base.OnCreate(savedInstanceState);
    
       var _raygunSettings = new RaygunSettings
       {
       ApiKey = "paste_your_api_key_here",
       CatchUnhandledExceptions = true // automatically reports any unhandled exceptions to Raygun
       };
    
       var _raygunClient = new RaygunClient(_raygunSettings); // Ideally add this as a service to inject
    }
    
  3. Configure Android Manifest: Ensure that your AndroidManifest file includes the necessary permissions for network access.

    <uses-permission android:name="android.permission.INTERNET" />
    
  4. Test Your Setup:

  • Simulate different crash scenarios in your development environment.
  • Verify that each exception is reported correctly in the Raygun dashboard.
  1. Deployment: Once configured and tested, deploy your application. Monitor error reports via the Raygun dashboard to ensure unhandled exceptions are being captured as expected.

By following these steps, your .NET Android application should be equipped with robust unhandled crash reporting, allowing you to maintain high performance and reliability.

For more detailed information and advanced configurations, please refer to the .NET 6+ documentation: Crash Reporting for .NET 6+.