From 4f81e767def3c83ddb4dd0dfbc8d53976d81f476 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Ricau Date: Thu, 1 Jun 2023 09:23:22 -0700 Subject: [PATCH] Fix crash from LifecycleRegistry kotlin conversion Fixes #2527 --- .../src/main/java/shark/AndroidObjectInspectors.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shark/shark-android/src/main/java/shark/AndroidObjectInspectors.kt b/shark/shark-android/src/main/java/shark/AndroidObjectInspectors.kt index cda50362cb..73e3e6cab1 100644 --- a/shark/shark-android/src/main/java/shark/AndroidObjectInspectors.kt +++ b/shark/shark-android/src/main/java/shark/AndroidObjectInspectors.kt @@ -854,7 +854,11 @@ enum class AndroidObjectInspectors : ObjectInspector { private val HeapInstance.lifecycleRegistryState: String get() { - val state = this["androidx.lifecycle.LifecycleRegistry", "mState"]!!.valueAsInstance!! + // LifecycleRegistry was converted to Kotlin + // https://cs.android.com/androidx/platform/frameworks/support/+/36833f9ab0c50bf449fc795e297a0e124df3356e + val stateField = this["androidx.lifecycle.LifecycleRegistry", "state"] + ?: this["androidx.lifecycle.LifecycleRegistry", "mState"]!! + val state = stateField.valueAsInstance!! return state["java.lang.Enum", "name"]!!.value.readAsJavaString()!! } },