CrashTrace is a lightweight Android crash analytics SDK designed to capture application crashes along with a timeline of user interactions leading up to the crash. Traditional crash reporters typically provide only stack traces and device information. While useful, this information often lacks context about what the user actually did before the crash happened. CrashTrace solves this problem by automatically tracking user interactions and screen navigation throughout the session and attaching that timeline to the crash report. This allows developers to reconstruct the user journey that led to the crash and significantly reduce debugging time.
This SDK is available on https://jitpack.io/ search for Phoenix1808/CrashTrace and then click get it. And ALL SET !!
The primary goal of CrashTrace is to provide developers with context-aware crash reports. Instead of only seeing where the crash occurred, developers can see the full interaction sequence that caused the crash.
Example crash timeline:
Session: 26aca110
Timeline:
Screen_open LoginActivity
ui_click loginButton
Screen_open HomeActivity
ui_click profileCard
ui_click editProfileButton
Crash
This helps developers answer questions like:
- What screen was the user on?
- What actions did the user perform?
- What sequence of events caused the crash?
CrashTrace SDK currently includes the following core features.
CrashTrace starts tracking when initialized inside the application.
CrashTrace.init(applicationContext)This setup automatically enables:
- session tracking
- activity lifecycle tracking
- UI interaction tracking
- crash interception
Each time the application launches, CrashTrace generates a unique session ID.
Example:
Session: 26aca110-4d91-4f07-b620-4cc0e2ba5969
This allows events and crashes to be grouped within a single user session.
Session tracking is handled by:
SessionManager.kt
CrashTrace uses Android's Application.ActivityLifecycleCallbacks to detect screen changes automatically.
When an activity becomes visible, the SDK records an event.
Example:
Event: Screen_open | Screen: MainActivity
This feature works automatically without requiring developers to manually instrument each activity.
Handled by:
ActivityTracker.kt
CrashTrace automatically tracks interactions with clickable UI elements.
Supported interactions include:
- Button clicks
- ImageView clicks
- CardView clicks
- FloatingActionButton clicks
- Any clickable view
Example event:
ui_click loginButton
The SDK traverses the entire view hierarchy of the activity and attaches listeners to clickable elements.
Handled by:
ClickTrackers.kt
Many applications already attach their own click listeners to views.
CrashTrace uses reflection to retrieve the existing listener and wrap it without breaking existing behavior.
Execution flow::
User Click
↓
CrashTrace logs interaction
↓
Original click listener executes
This ensures:
- zero interference with app logic
- seamless integration
Handled by:
ReflectionUtils.kt
User interactions and screen transitions are stored inside an event buffer.
Example buffer contents:
Screen_open LoginActivity
ui_click loginButton
Screen_open HomeActivity
ui_click profileCard
The buffer maintains the most recent events before a crash occurs.
Handled by:
EventBuffer.kt
CrashTrace intercepts application crashes using Android's uncaught exception handler.
Thread.setDefaultUncaughtExceptionHandler()When a crash occurs the SDK captures:
- crash message
- current session
- recent user events
Example output:
App Crash Detected
Crash Msg: Test Crash
Session: 26aca110
Handled by:
CrashHandler.kt
CrashTrace constructs a structured crash report object containing all relevant data.
Example structure:
CrashReport(
sessionId,
crashMessage,
screen,
timeline,
timestamp
)
Handled by:
CrashReport.kt
CrashReportBuilder.kt
The crash report is converted into JSON format so that it can be transmitted to a backend service.
Example JSON output:
{
"sessionId": "26aca110",
"crashMessage": "Test Crash",
"screen": "MainActivity",
"timestamp": 171060000,
"timeline": [
"Screen_open MainActivity",
"ui_click loginButton"
]
}Handled by:
CrashReportSerializer.kt
crashtrace-sdk
│
core
│
├── CrashTrace.kt
├── CrashHandler.kt
├── SessionManager.kt
├── ActivityTracker.kt
├── ClickTrackers.kt
├── ReflectionUtils.kt
├── EventTrackers.kt
├── EventBuffer.kt
├── CrashReport.kt
├── CrashReportBuilder.kt
└── CrashReportSerializer.kt
The complete SDK execution pipeline works as follows:
App Start
↓
CrashTrace.init()
↓
Session Created
↓
Activity Lifecycle Hooked
↓
Screen Events Captured
↓
User Interaction Events Captured
↓
Events Stored in EventBuffer
↓
Crash Occurs
↓
CrashHandler Intercepts Crash
↓
CrashReportBuilder Builds Report
↓
CrashReportSerializer Converts to JSON
The current SDK implements the core crash tracking engine. Future development will include:
Crash reports will include additional metadata such as:
- device model
- android version
- app version
- manufacturer
Example:
{
"device": "Pixel 6",
"android": "14",
"appVersion": "1.0.0"
}The SDK will send crash reports to a backend server.
POST /crash-report
This allows centralized crash storage and monitoring.
A web interface will allow developers to view crash reports and inspect event timelines.
Example flow:
Crash List
↓
Open Crash
↓
View User Timeline
Future analytics may include:
- most crashing screen
- most frequent crash flow
- crash frequency statistics
- session insights
Most crash analytics tools focus on:
stacktrace
exception type
device info
CrashTrace focuses on user context.
Key differentiators:
CrashTrace reconstructs the exact user journey before a crash.
The SDK is designed to be minimal and dependency-free.
Developers do not need to manually instrument UI events.
CrashTrace captures interactions even when existing click listeners are present.
Crash reports are already structured as JSON, making server integration straightforward.
SDK Core ████████████████████ 95%
Backend API ░░░░░░░░░░░░░░░░░░░░
Dashboard ░░░░░░░░░░░░░░░░░░░░
The core SDK engineering is essentially complete.
Upcoming work will focus on backend services and crash visualization tools.
This project demonstrates key Android engineering concepts including:
- Android SDK development
- Activity lifecycle hooks
- view hierarchy traversal
- reflection in Android
- event buffering systems
- crash interception mechanisms
- JSON serialization
- modular SDK architecture design
Divyansh Goyal
Android Developer
MIT License