I've spent the better part of 2 days on the following issue and I'm running out of ideas. Hopefully someone has had a similar experience and can help me out.
I have a .NET 8.0 iOS, Windows, and Android app with a shared backend. Exception logging to application insights is working perfectly for iOS and Windows, but it only works for Android in the DEBUG configuration of my app.
Reproduction
Instantiating the telemetry client during app start:
var telemetryConfiguration = TelemetryConfiguration.CreateDefault();
var telemetryConnection = config["ApplicationInsightsConnection"];
telemetryConfiguration.ConnectionString = telemetryConnection;
var telemetryClient = new TelemetryClient(telemetryConfiguration);
Mvx.IoCProvider.RegisterSingleton(telemetryClient);
Writing an Event or Exception to Application Insights:
/// <inheritdoc />
public void LogException(Exception exception, string? message, IDictionary<string, string> properties)
{
var telemetryClient = Mvx.IoCProvider?.Resolve<TelemetryClient>();
// Both Don't work
telemetryClient?.TrackException(new ExceptionTelemetry(new Exception("Test Thomas Release Config")));
telemetryClient?.TrackEvent("Test Thomas Release Config");
}
Expected behavior
On Android, after compiling my app in Release Mode, I expect exceptions that I send with telemetryClient.Track to be visible in Application insights.
Relevant package, tooling and runtime versions
Application insights version 2.22.0 Platform: .Net 8 app, Android (no Maui).
Additional Context
The answer to this was actually very simple. The "Internet" permission is required. It turns out this gets added automatically by the ApplicationCenter packages, but not by the Application Insights packages.
<uses-permission android:name="android.permission.INTERNET" />