Bird
Raised Fist0
Firebasecloud~10 mins

Crashlytics setup in Firebase - Step-by-Step Execution

Choose your learning style10 modes available
Process Flow - Crashlytics setup
Add Firebase to Project
↓
Add Crashlytics SDK
↓
Initialize Crashlytics in App
↓
Build and Run App
↓
Crashlytics Uploads Crash Reports
↓
View Crash Reports in Firebase Console
This flow shows the steps to set up Crashlytics: add Firebase, add SDK, initialize, run app, upload crash data, and view reports.
Execution Sample
Firebase
dependencies {
  implementation 'com.google.firebase:firebase-crashlytics:18.3.7'
}

FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true);
This code adds the Crashlytics SDK to the app and enables crash report collection.
Process Table
StepActionResultNext Step
1Add Firebase to projectFirebase project created and linkedAdd Crashlytics SDK
2Add Crashlytics SDK to appCrashlytics library included in buildInitialize Crashlytics in app code
3Initialize Crashlytics in appCrashlytics ready to capture crashesBuild and run app
4Build and run appApp runs with Crashlytics enabledCrashlytics collects crash data on failure
5Crash occurs in appCrashlytics captures crash reportUpload crash report to Firebase
6Crash report uploadedCrash data available in Firebase ConsoleView crash reports
7View crash reportsDeveloper sees crash details and stack tracesSetup complete
💡 Setup ends when crash reports are visible in Firebase Console
Status Tracker
VariableStartAfter Step 2After Step 3After Step 4After Step 6
Firebase ProjectNoneCreatedCreatedCreatedCreated
Crashlytics SDKNot addedAddedAddedAddedAdded
Crashlytics InitializedFalseFalseTrueTrueTrue
Crash Reports CollectedNoneNoneNoneCollectingUploaded
Key Moments - 3 Insights
Why do we need to initialize Crashlytics in the app code after adding the SDK?
Initialization activates Crashlytics to start capturing crashes; without it, the SDK is present but inactive (see execution_table step 3).
What happens if the app crashes before Crashlytics is initialized?
Crash reports won't be captured or uploaded because Crashlytics isn't active yet (refer to variable_tracker 'Crashlytics Initialized' before step 3).
Why must we build and run the app after setup?
Running the app triggers Crashlytics to start collecting crash data and upload reports on failures (execution_table step 4 and 5).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step is Crashlytics first ready to capture crashes?
AStep 4
BStep 2
CStep 3
DStep 5
💡 Hint
Check the 'Result' column for when Crashlytics is initialized (step 3).
According to variable_tracker, when do crash reports start being collected?
AAfter Step 4
BAfter Step 3
CAfter Step 2
DAfter Step 6
💡 Hint
Look at 'Crash Reports Collected' variable changes in variable_tracker.
If you skip initializing Crashlytics in the app, what will happen?
ACrash reports will still be collected
BCrash reports won't be collected
CApp will not build
DFirebase project won't be created
💡 Hint
Refer to key_moments about initialization importance and execution_table step 3.
Concept Snapshot
Crashlytics setup steps:
1. Add Firebase project
2. Add Crashlytics SDK to app
3. Initialize Crashlytics in app code
4. Build and run app
5. Crashlytics collects and uploads crash reports
6. View reports in Firebase Console
Initialization is key to activate crash capturing.
Full Transcript
To set up Crashlytics, first create and link a Firebase project. Then add the Crashlytics SDK to your app's dependencies. Next, initialize Crashlytics in your app code to enable crash capturing. Build and run the app so Crashlytics can start collecting crash data. When the app crashes, Crashlytics captures and uploads the report to Firebase. Finally, view the crash reports in the Firebase Console to monitor app stability. Initialization is essential; without it, crash data won't be collected.

Practice

(1/5)
1. What is the primary purpose of Firebase Crashlytics in an app?
easy
A. To automatically detect and report app crashes
B. To store user data securely
C. To manage app user authentication
D. To optimize app performance speed

Solution

  1. Step 1: Understand Crashlytics function

    Crashlytics is designed to catch app crashes and send reports automatically to Firebase Console.
  2. Step 2: Compare with other Firebase features

    Other options like data storage, authentication, and performance are handled by different Firebase services.
  3. Final Answer:

    To automatically detect and report app crashes -> Option A
  4. Quick Check:

    Crashlytics = crash reporting [OK]
Hint: Crashlytics = crash reports, not data or auth [OK]
Common Mistakes:
  • Confusing Crashlytics with Firebase Authentication
  • Thinking Crashlytics manages user data
  • Assuming Crashlytics improves app speed
2. Which of the following is the correct step to initialize Crashlytics in an Android app's onCreate() method?
easy
A. FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true);
B. Crashlytics.initializeCrashlytics();
C. FirebaseApp.initializeApp(this);
D. Crashlytics.startCrashlyticsSession();

Solution

  1. Step 1: Identify correct Crashlytics initialization

    The official way to enable Crashlytics collection is calling FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true);.
  2. Step 2: Check other options

    Crashlytics.initializeCrashlytics() and Crashlytics.startCrashlyticsSession() are not valid Firebase SDK methods. FirebaseApp.initializeApp(this); initializes Firebase but not Crashlytics specifically.
  3. Final Answer:

    FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true); -> Option A
  4. Quick Check:

    Enable Crashlytics with setCrashlyticsCollectionEnabled(true) [OK]
Hint: Use FirebaseCrashlytics.getInstance() to enable collection [OK]
Common Mistakes:
  • Using non-existent Crashlytics methods
  • Confusing FirebaseApp initialization with Crashlytics setup
  • Forgetting to enable crash collection explicitly
3. Given this Android code snippet, what will happen when the app runs?
FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
crashlytics.log("User clicked button");
throw new RuntimeException("Test crash");
medium
A. The app logs the message but does not crash
B. The app ignores the exception and continues running
C. The app crashes silently without logging
D. The app logs the message and crashes, sending a report to Firebase

Solution

  1. Step 1: Analyze the code behavior

    The code logs a message to Crashlytics and then throws a RuntimeException, which causes the app to crash.
  2. Step 2: Understand Crashlytics reporting

    Crashlytics captures the log and crash, then sends the crash report to Firebase Console for analysis.
  3. Final Answer:

    The app logs the message and crashes, sending a report to Firebase -> Option D
  4. Quick Check:

    Crashlytics logs + crash = report sent [OK]
Hint: Throw exception after logging to test Crashlytics [OK]
Common Mistakes:
  • Thinking the app won't crash after exception
  • Assuming logs are not sent with crash
  • Believing the app ignores exceptions
4. You added Crashlytics to your iOS app but no crash reports appear in Firebase Console after forcing a crash. What is the most likely mistake?
medium
A. Calling Crashlytics.crash() before initializing Firebase
B. Forgetting to enable Crashlytics in Firebase Console
C. Not calling FirebaseApp.configure() in application(_:didFinishLaunchingWithOptions:)
D. Using an unsupported iOS version

Solution

  1. Step 1: Check Firebase initialization

    Calling FirebaseApp.configure() is required but usually done correctly if app runs.
  2. Step 2: Verify Crashlytics enablement in Console

    Crashlytics must be enabled in Firebase Console to receive reports; forgetting this is a common cause of missing reports.
  3. Step 3: Consider other options

    Calling crash before initialization or unsupported iOS versions are less common and usually cause app errors.
  4. Final Answer:

    Forgetting to enable Crashlytics in Firebase Console -> Option B
  5. Quick Check:

    Enable Crashlytics in Console to get reports [OK]
Hint: Always enable Crashlytics in Firebase Console after setup [OK]
Common Mistakes:
  • Skipping Crashlytics enablement in Firebase Console
  • Initializing Firebase incorrectly
  • Assuming all iOS versions are supported
5. You want to test Crashlytics setup by forcing a crash in your Android app. Which code snippet correctly triggers a test crash that will appear in Firebase Console?
hard
A. FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(false);
B. FirebaseCrashlytics.getInstance().log("Crash test");
C. throw new RuntimeException("Test Crash");
D. FirebaseCrashlytics.getInstance().recordException(new Exception("Test"));

Solution

  1. Step 1: Identify code that forces a crash

    Throwing a RuntimeException immediately crashes the app, which Crashlytics detects and reports.
  2. Step 2: Understand other options

    Logging or recording exceptions do not force a crash. Disabling collection prevents reporting.
  3. Final Answer:

    throw new RuntimeException("Test Crash"); -> Option C
  4. Quick Check:

    Throw exception to force crash for testing [OK]
Hint: Throw exception to force crash, not just log [OK]
Common Mistakes:
  • Using log or recordException without crashing
  • Disabling Crashlytics collection by mistake
  • Expecting logs alone to trigger crash reports
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard