leakcanary: Crash during espresso tests

We have a crash:


05-06 11:09:32.164 | error | AndroidRuntime | FATAL EXCEPTION: IntentService[leakcanary.internal.AnalysisResultService]
-- | -- | -- | --
05-06 11:09:32.164 | error | AndroidRuntime | Process: com.yolt.mobile.aws, PID: 4762
05-06 11:09:32.164 | error | AndroidRuntime | java.util.NoSuchElementException: List is empty.
05-06 11:09:32.164 | error | AndroidRuntime | at kotlin.collections.CollectionsKt___CollectionsKt.first(_Collections.kt:194)
05-06 11:09:32.164 | error | AndroidRuntime | at leakcanary.internal.activity.db.LeakingInstanceTable.createGroupDescription(LeakingInstanceTable.kt:262)
05-06 11:09:32.164 | error | AndroidRuntime | at leakcanary.internal.activity.db.LeakingInstanceTable.insert(LeakingInstanceTable.kt:44)
05-06 11:09:32.164 | error | AndroidRuntime | at leakcanary.internal.activity.db.HeapAnalysisTable.insert(HeapAnalysisTable.kt:53)
05-06 11:09:32.164 | error | AndroidRuntime | at leakcanary.internal.AnalysisResultService.onHeapAnalyzed(AnalysisResultService.kt:91)
05-06 11:09:32.164 | error | AndroidRuntime | at leakcanary.internal.AnalysisResultService.onHandleIntentInForeground(AnalysisResultService.kt:70)
05-06 11:09:32.164 | error | AndroidRuntime | at leakcanary.internal.ForegroundService.onHandleIntent(ForegroundService.kt:56)
05-06 11:09:32.164 | error | AndroidRuntime | at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:68)
05-06 11:09:32.164 | error | AndroidRuntime | at android.os.Handler.dispatchMessage(Handler.java:102)
05-06 11:09:32.164 | error | AndroidRuntime | at android.os.Looper.loop(Looper.java:154)
05-06 11:09:32.164 | error | AndroidRuntime | at android.os.HandlerThread.run(HandlerThread.java:61)


It happened during our automated tests and I see from the log that LeakCanary detected a leak.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Sound like you don’t have it.

Then you should add new class to espresso test:

class <My>InstrumentationRunner : AndroidJUnitRunner() 

Then you should also define it in your build.gradle:

android {
  ...
  defaultConfig {
    ...
    testInstrumentationRunner 'com.<yourpackge>.<My>InstrumentationRunner'
  }
}

And then, in this runner, you should override onStart method.