Firebase Crashlytics helps you track app crashes in real-time, providing detailed reports to fix issues quickly. It integrates seamlessly with Capacitor for both iOS and Android apps. Here’s what you need to know:
-
Why Use Crashlytics?
- Get real-time crash alerts.
- Analyze detailed crash reports with automatic issue grouping.
- Monitor critical errors to keep apps stable.
-
Setup Requirements:
- Install Node.js (v16+), Capacitor (v4+), and tools like Xcode 14+ and Android Studio Electric Eel.
- Download Firebase configuration files (
GoogleService-Info.plist
for iOS,google-services.json
for Android). - Update platform-specific files like
Podfile
(iOS) andbuild.gradle
(Android).
-
Key Steps:
-
Install Crashlytics:
Terminal window npm install @capacitor-firebase/crashlytics && npx cap sync -
Initialize Crashlytics in your app:
import { FirebaseCrashlytics } from '@capacitor-firebase/crashlytics';await FirebaseCrashlytics.initialize();
-
-
Test Your Setup:
-
Trigger a test crash:
await FirebaseCrashlytics.crash();
-
-
Bonus Tip: Combine Crashlytics with Capgo for instant live updates without app store delays.
This guide ensures your app is crash-free and user-friendly. Start by setting up Firebase Crashlytics today!
2021 Android Guide: Firebase Crashlytics - custom crash …
Setup Requirements
Before diving in, make sure you’ve completed the following steps:
Required Software and Accounts
You’ll need to install the following:
- Node.js (v16 or higher) and Capacitor (v4 or higher)
- A Firebase account with an active project
- Xcode 14+ for iOS development
- Android Studio Electric Eel or a newer version for Android development
- The latest version of CocoaPods (required for iOS)
Platform Configuration Files
For iOS:
- Download the
GoogleService-Info.plist
file from the Firebase Console. - Update your
Podfile
to include Crashlytics dependencies. - Add the necessary privacy keys to your
Info.plist
file.
For Android:
- Obtain the
google-services.json
file from the Firebase Console. - Make changes to both the project-level and app-level
build.gradle
files. - Update the
AndroidManifest.xml
to include the required permissions.
Firebase Console Setup
Set up Firebase and enable Crashlytics through these steps:
-
Create a Firebase project and enable Crashlytics.
-
Register your apps in the Firebase Console:
- Use the bundle ID for iOS and the package name for Android.
- Download the configuration files:
GoogleService-Info.plist
(iOS) andgoogle-services.json
(Android).
-
Integrate Firebase SDKs into your app by adding these dependencies:
For Android (app-level
build.gradle
):dependencies {implementation platform('com.google.firebase:firebase-bom:32.0.0')implementation 'com.google.firebase:firebase-crashlytics'implementation 'com.google.firebase:firebase-analytics'}For iOS (
Podfile
):pod 'Firebase/Crashlytics'pod 'Firebase/Analytics'
Once these steps are complete, you’re ready to move on to the Plugin Installation section.
Installation Steps
Plugin Installation
First, install the plugin and sync it with Capacitor:
npm install @capacitor-firebase/crashlytics && npx cap sync
Then, initialize Crashlytics in your app. Add the following code to app.component.ts
or main.ts
:
import { FirebaseCrashlytics } from '@capacitor-firebase/crashlytics';await FirebaseCrashlytics.initialize();
Platform Configuration
Set up the required configurations for Android and iOS platforms.
Android Setup
-
Add the Crashlytics Gradle plugin to your app-level
build.gradle
file:buildscript {dependencies {classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.5'}}apply plugin: 'com.google.firebase.crashlytics' -
Enable crash collection in
AndroidManifest.xml
:<meta-dataandroid:name="firebase_crashlytics_collection_enabled"android:value="true" />
iOS Setup
-
Configure Firebase in
AppDelegate.swift
:import FirebaseFirebaseApp.configure()
Testing Your Setup
Confirm that Crashlytics is working by running a test crash and checking the Firebase Console:
-
Trigger a test crash with a custom key:
await FirebaseCrashlytics.setCustomKey({key: 'test_scenario', value: 'manual_crash'});await FirebaseCrashlytics.crash(); -
Optionally, identify a user:
await FirebaseCrashlytics.setUserId({userId: 'user123'}); -
Log custom events:
await FirebaseCrashlytics.log({message: 'Test crash triggered'});
Reports, including stack traces, device details, and custom keys, should appear in the Firebase Console within about 5 minutes.
Important: Remove crash calls before releasing your app. To disable crash collection during development, use:
await FirebaseCrashlytics.setCrashlyticsCollectionEnabled({enabled: false});
Monitoring Guide
Once you’ve confirmed your setup with a test crash, use the Firebase Console to track actual crashes and errors in your live app.
Reading Crash Reports
You can find crash reports in the Firebase Console under the Crashlytics section. Here’s what you’ll see:
- Crash-free users: The percentage of users who haven’t experienced crashes.
- Issue stability: How often crashes are occurring.
- Impact analysis: The number of users affected.
Click on any issue to dive deeper into details like stack traces, device information (e.g., OS version, memory), custom keys, logs, and the user’s journey leading up to the crash.
Pro tip: Enable the “velocity alerts” feature to get notified when crash rates suddenly increase. This can help you address problems before they impact too many users.
Error Management Tips
-
Prioritize by Impact: Focus on crashes that affect the most users or occur in critical parts of your app. Tracking trends can help you identify urgent issues.
-
Use Custom Keys: Add context to your crash reports with custom keys. For example:
await FirebaseCrashlytics.setCustomKey({key: 'current_view',value: 'payment_processing'}); -
Group Similar Issues: Take advantage of Firebase’s automatic issue grouping. You can also tag related crashes with consistent custom keys and use clear, descriptive titles for easier tracking.
Protecting User Privacy
To ensure compliance and safeguard user data, follow these guidelines:
-
Permissions:
- Mention crash reporting in your privacy policy.
- Get user consent for data collection in regions with GDPR regulations.
- Provide users with an option to opt-out of crash reporting.
-
Data Collection Controls:
await FirebaseCrashlytics.setCrashlyticsCollectionEnabled({enabled: false});await FirebaseCrashlytics.setCrashlyticsCollectionEnabled({enabled: true}); -
Data Retention:
- Set up automatic data deletion after 90 days.
- Scrub sensitive information from your reports.
- Use non-identifiable custom keys to maintain user privacy while debugging.
Capgo Integration
Streamline the process from crash detection to fix deployment by pairing Capgo’s live update system with Crashlytics.
About Capgo
Capgo is a live update tool designed specifically for Capacitor apps. With over 1,900 apps in production and a 95% update rate within 24 hours, it ensures quick fixes without the delays of app store approvals [1].
Key features include:
- End-to-end encryption for secure updates
- One-click rollback to previous versions
- Channel-based distribution for targeted releases
- Seamless CI/CD integration
- A 100% open-source platform
Crashlytics and Capgo Together
Using Crashlytics with Capgo creates an efficient workflow for identifying and resolving issues quickly.
Here’s how it works:
-
Crash Detection and Response
Crashlytics identifies a crash, and Capgo allows you to deploy fixes instantly without waiting for app store approval. -
Targeted Updates
- Beta Testing: Test fixes with a specific group to ensure they are effective.
- Staged Rollout: Gradually deploy updates to reduce risks.
- Emergency Fix: Quickly push critical patches to resolve urgent issues.
-
Monitoring and Verification
After deploying updates with Capgo, use Crashlytics to track crash rates and confirm the issue is resolved.
Security and App Store Rules
Capgo adheres to Apple and Google’s policies while providing strong security features:
- 82% global success rate for delivering updates [1]
- Automatic version control for better organization
- Compliance with app store live update guidelines
For secure integration with Crashlytics:
- Enable error tracking in both systems.
- Use Capgo’s monitoring tools alongside Crashlytics reports.
- Maintain version control for all updates.
- Keep detailed logs of updates for auditing purposes.
Continue to the Plugin Options section to explore other live update tools.
Plugin Options
Choosing the right crash-reporting plugin can greatly impact how you identify and fix errors in your app.
Here’s a quick comparison of Crashlytics with other popular error-reporting tools for Capacitor:
- Sentry: Offers a free tier with paid plans starting at $26/month. Supports over 30 platforms and provides real-time error monitoring with detailed context.
- Bugsnag: Starts at $47/month. Covers both mobile and web platforms, featuring automatic error grouping and release tracking.
- Rollbar: Priced from $31/month. Works across multiple platforms, with features like deployment tracking and person tracking.
Crashlytics is especially appealing for teams already using Firebase, thanks to its smooth integration and a free tier.
Summary
Here’s a quick look at what you’ve accomplished and what comes next:
Setup Steps Recap
You’ve completed three key steps to get started:
- Created a Firebase project and registered your iOS/Android apps.
- Installed and configured the Crashlytics plugin.
- Updated the necessary iOS and Android platform files.
Why Integrate These Tools?
Pairing Firebase Crashlytics with Capgo gives you a powerful system for error tracking and update management. Here’s what this combo offers:
- Quick fixes: Push instant updates and roll back changes with just one click.
- Reliable rollouts: Ensure updates are widely adopted and smoothly delivered to users.
What’s Next?
- Turn on detailed crash analytics in the Firebase Console.
- Add Capgo to your CI/CD pipeline for streamlined updates.
- Use Capgo channels to test and release fixes step by step.
With Crashlytics and Capgo in place, you’re set to keep your app running smoothly and improving over time.