📖 Scenario: You are building a mobile app and want to track crashes to improve app stability. You will set up Firebase Crashlytics to report crashes automatically.
🎯 Goal: Configure Firebase Crashlytics in your app to capture and report crashes.
📋 What You'll Learn
Create a Firebase configuration dictionary with the exact project ID and app ID
Add a configuration variable to enable Crashlytics collection
Initialize Firebase Crashlytics with the configuration
Complete the setup by enabling automatic crash reporting
💡 Why This Matters
🌍 Real World
Crash reporting helps developers find and fix app errors quickly, improving user experience.
💼 Career
Setting up crash reporting is a common task for mobile developers and cloud engineers working with Firebase.
Progress0 / 4 steps
1
Create Firebase configuration dictionary
Create a dictionary called firebase_config with these exact entries: 'projectId': 'my-firebase-project' and 'appId': '1:1234567890:android:abcdef123456'.
Firebase
Hint
Use a Python dictionary with keys 'projectId' and 'appId' exactly as shown.
2
Add Crashlytics collection enabled flag
Add a boolean variable called crashlytics_collection_enabled and set it to True to enable crash reporting.
Firebase
Hint
Set the variable exactly as crashlytics_collection_enabled = True.
3
Initialize Firebase Crashlytics
Write a function called initialize_crashlytics that takes config and enabled as parameters and returns a dictionary with keys 'config' and 'collection_enabled' set to the passed values.
Firebase
Hint
Define a function that returns a dictionary with the given parameters.
4
Enable automatic crash reporting
Call the function initialize_crashlytics with firebase_config and crashlytics_collection_enabled and assign the result to a variable called crashlytics_setup.
Firebase
Hint
Call the function with the two variables and assign the result to crashlytics_setup.
Practice
(1/5)
1. What is the main purpose of Firebase Crashlytics in an app?
easy
A. To store user data securely
B. To manage user authentication
C. To improve app loading speed
D. To automatically collect and report app crashes
Solution
Step 1: Understand Crashlytics role
Firebase Crashlytics is designed to track and report app crashes automatically.
Step 2: Compare with other options
Storing user data, improving speed, and managing authentication are not Crashlytics functions.
Final Answer:
To automatically collect and report app crashes -> Option D
Quick Check:
Crashlytics = crash reporting [OK]
Hint: Crashlytics = crash reports, not data or speed [OK]
Common Mistakes:
Confusing Crashlytics with user data storage
Thinking it speeds up the app
Mixing it with authentication services
2. Which Firebase Crashlytics method is used to log custom messages before a crash?
easy
A. crashlytics.sendReport()
B. crashlytics.recordError()
C. crashlytics.log()
D. crashlytics.startSession()
Solution
Step 1: Identify logging method
The method to add custom logs before a crash is crashlytics.log().
Step 2: Understand other methods
recordError() reports errors, sendReport() and startSession() are not valid Crashlytics methods.
Final Answer:
crashlytics.log() -> Option C
Quick Check:
Logging = crashlytics.log() [OK]
Hint: Use .log() to add messages before crash [OK]
Common Mistakes:
Using recordError() to log messages
Assuming sendReport() exists
Confusing startSession() with logging
3. Given this code snippet, what will Crashlytics report?