Created
June 14, 2024 12:29
-
-
Save ali-star/5512a2e3b9ce31aee302b99245a53161 to your computer and use it in GitHub Desktop.
Upload the leaks to Firebase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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