Skip to content

Instantly share code, notes, and snippets.

@ali-star
Created June 14, 2024 12:29
Show Gist options
  • Save ali-star/5512a2e3b9ce31aee302b99245a53161 to your computer and use it in GitHub Desktop.
Save ali-star/5512a2e3b9ce31aee302b99245a53161 to your computer and use it in GitHub Desktop.
Upload the leaks to Firebase
class DebugApplication : Application() {
override fun onCreate() {
super.onCreate()
val analysisUploadListener = EventListener { event ->
if (event is EventListener.Event.HeapAnalysisDone.HeapAnalysisSucceeded) {
val heapAnalysis = event.heapAnalysis
heapAnalysis.allLeaks.forEach { leak ->
Firebase.crashlytics.recordException(leak.toThrowable())
}
}
}
LeakCanary.config = LeakCanary.config.run {
copy(eventListeners = eventListeners + analysisUploadListener)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment