Skip to content

A Carbon app is not inspectable with the Layout Inspector #439

@jlauridsen

Description

@jlauridsen

Steps to reproduce:

  1. Run the sample Carbon application on an API 33 emulator
  2. In Android Studio: Open the Layout Inspector and connect to the app
  3. Select LinearLayout in the component tree of the Layout Inspector

Exception seen in logcat:
tk.zielony.carbonsamples E Inspector layoutinspector.view.inspection crashed
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.res.ColorStateList.getDefaultColor()' on a null object reference
at carbon.widget.LinearLayout.getOutlineAmbientShadowColor(LinearLayout.java:788)
at android.view.View$InspectionCompanion.readProperties(View$InspectionCompanion.java:768)
at android.view.View$InspectionCompanion.readProperties(View$InspectionCompanion.java:18)
at com.android.tools.agent.appinspection.proto.property.PropertyCache$Data.readProperties(PropertyCache.kt:44)
at com.android.tools.agent.appinspection.proto.ViewExtensionsKt.createPropertyGroupImpl(ViewExtensions.kt:223)
at com.android.tools.agent.appinspection.proto.ViewExtensionsKt.createPropertyGroup(ViewExtensions.kt:191)
at com.android.tools.agent.appinspection.proto.ViewExtensionsKt.createGetPropertiesResponse(ViewExtensions.kt:181)
at com.android.tools.agent.appinspection.ViewLayoutInspector$handleGetProperties$1$1.run(ViewLayoutInspector.kt:788)
at com.android.tools.agent.app.inspection.concurrent.HandlerThreadExecutor$SafeHandler.dispatchMessage(HandlerThreadExecutor.java:71)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.os.HandlerThread.run(HandlerThread.java:67)

This is because carbon.widget.LinearLayout.getOutlineAmbientShadowColor is dereferencing the ambitneShadowColor unconditionally when it is null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions