A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
Hi @Yeswanth Srikanth ,
Thank you for your inquiry.
I have implemented firebase analytics and crashlytics in my MAUI app and I want to share how I do, you can refer to these following steps:
Step 1: Create your Firebase project
- Go to https://console.firebase.google.com
- Click Add project → give it a name → continue → enable Google Analytics → finish.
- In the project overview, click the Android icon → register your app:
- Package name = exactly the same as your MAUI app’s Package in the AndroidManifest (usually something like com.yourcompany.yourapp).
- Download the google-services.json file.
- Click the iOS icon → register your app:
- Bundle ID = exactly the same as your MAUI app’s Bundle Identifier.
- Download the GoogleService-Info.plist file.
Step 2: Add the config files to your MAUI project In your MAUI solution:
- Put google-services.json in the root (or Platforms/Android folder).
- Put GoogleService-Info.plist in the root (or Platforms/iOS folder).
Now edit your .csproj file (right-click project → Edit Project File) and add this inside the <Project> tag:
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<GoogleServicesJson Include="google-services.json" />
</ItemGroup>
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
<BundleResource Include="GoogleService-Info.plist" />
</ItemGroup>
Right-click each file in Solution Explorer:
- google-services.json → Build Action = GoogleServicesJson
- GoogleService-Info.plist → Build Action = Bundle Resource.
Step 3: Add strings.xml file by going to exact folder in your project: Platforms/Android/Resources/values/ (folder ios is similar)
Inside that folder, create a new file called strings.xml (if it does not exists).
Then, put this content inside strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="com.google.firebase.crashlytics.mapping_file_id">none</string>
<string name="com.crashlytics.android.build_id">1.0</string>
</resources>
- Right-click the
strings.xmlfile in Solution Explorer. - Choose Properties.
- Set Build Action to AndroidResource.
- Clean + Rebuild + Run Clean the solution → Rebuild → Run on Android device/emulator.
Step 4: Install the NuGet packages In your MAUI project, install these three packages:
- Plugin.Firebase
- Plugin.Firebase.Analytics
- Plugin.Firebase.Crashlytics
You can do it in the NuGet Package Manager or with these commands in the Package Manager Console:
Install-Package Plugin.Firebase
Install-Package Plugin.Firebase.Analytics
Install-Package Plugin.Firebase.Crashlytics
Step 5: Initialize Firebase in code
You can refer to following example code:
using Microsoft.Maui.LifecycleEvents;
using Plugin.Firebase;
using Plugin.Firebase.Analytics;
using Plugin.Firebase.Crashlytics;
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder.UseMauiApp<App>()
.ConfigureFonts(fonts => { ... }); // your existing code
builder.ConfigureLifecycleEvents(events =>
{
#if ANDROID
events.AddAndroid(android => android.OnCreate((activity, _) =>
{
CrossFirebase.Initialize(activity, () => Platform.CurrentActivity);
}));
#elif IOS
events.AddiOS(iOS => iOS.WillFinishLaunching((_, __) =>
{
CrossFirebase.Initialize(new CrossFirebaseSettings());
return false;
}));
#endif
});
CrossFirebaseCrashlytics.Current.SetCrashlyticsCollectionEnabled(true);
return builder.Build();
}
Step 6: Log analytics events
Anywhere in your code (for example in a button click):
using Plugin.Firebase.Analytics;
CrossFirebaseAnalytics.Current.LogEvent("button_clicked", new Dictionary<string, object>
{
{ "button_name", "Login" },
{ "user_id", "12345" }
});
You’ll see it live in Firebase Console → Analytics → Events
Step 7: Test Crashlytics (force a crash)
Please add a test button somewhere:
private void TestCrash(object sender, EventArgs e)
{
throw new Exception("This is my test crash for POC!");
}
Run the app without the debugger attached (important on iOS):
- Android: just run → crash → restart app → wait 30 seconds → check Firebase Console → Crashlytics.
- iOS: same, but make sure you’re not debugging.
Crashes appear in Firebase Console → Crashlytics.
I hope this addresses your concern. If the response was useful, please consider providing feedback by following the guidance.