I haven't been able to get the Android Studio Layout Inspector to work for some time on a specific project. I have tried few things found from searching around, like upgrading AS and restoring to the default settings. I am currently using the inspector image for "API 31 and T" I have also tried the others.
Looking in the idea log file, I see this exception when loading the Inspector.
2022-05-19 16:19:35,530 [ 802382] INFO - transport.TransportFileManager - Pushing layoutinspector-view-inspection.jar to /data/local/tmp/perfd/...
2022-05-19 16:19:35,666 [ 802518] INFO - transport.TransportFileManager - Successfully pushed layoutinspector-view-inspection.jar to /data/local/tmp/perfd/.
2022-05-19 16:19:35,989 [ 802841] WARN - ayoutinspector.LayoutInspector - java.lang.NoSuchMethodError: No static method mapNotNull(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence; in class Lkotlin/sequences/SequencesKt; or its super classes (declaration of 'kotlin.sequences.SequencesKt' appears in /data/app/~~O7aoUUFLvI3ubR8HLfx25g==/com.something.android.debug-ZXXoStc-19BHJGftwM6nRw==/base.apk!classes2.dex)
at com.android.tools.agent.appinspection.framework.SkiaQWorkaround.getFieldValue(SkiaQWorkaround.kt:43)
at com.android.tools.agent.appinspection.framework.SkiaQWorkaround.startRenderingCommandsCapture(SkiaQWorkaround.kt:66)
at com.android.tools.agent.appinspection.ViewLayoutInspector.startCapturing(ViewLayoutInspector.kt:371)
at com.android.tools.agent.appinspection.ViewLayoutInspector.access$startCapturing(ViewLayoutInspector.kt:71)
at com.android.tools.agent.appinspection.ViewLayoutInspector$handleStartFetchCommand$3.invoke(ViewLayoutInspector.kt:412)
at com.android.tools.agent.appinspection.ViewLayoutInspector$handleStartFetchCommand$3.invoke(ViewLayoutInspector.kt:410)
at com.android.tools.agent.appinspection.util.ThreadUtils$runOnMainThread$1.run(ThreadUtils.kt:56)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7842)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
I figured from the error that these functions were not being included in the final apk. I wrote some code that would force it to be included like:
But the list of functions kept growing. Looking into why these functions were not there in the first place, I saw that another developer had enabled minification for the debug build.
I changed it to false and the Layout Inspector now works!