Skip to content

Hyperion-Attr. Crash when inspecting view with programmaticaly set id #258

@VadimB95

Description

@VadimB95

Versions: 0.9.34-0.9.37
Device: any

Steps to reproduce

  1. Add view to layout without id or inflate it programmaticaly
  2. Set view id to any value or generate value using View.generateViewId()
  3. Launch the app
  4. In attribute inspector mode click on that view. Probably some scroll is needed in attributes dialog list until the row representing view id is visible.

Actual: crash
Expected: no crash. View id value shows empty string.

Stacktrace:

 App defined error. android.content.res.Resources$NotFoundException: Unable to find resource ID #0x14
 Caused by: android.content.res.Resources$NotFoundException: Unable to find resource ID #0x14
 	at android.content.res.ResourcesImpl.getResourceEntryName(ResourcesImpl.java:289)
 	at android.content.res.Resources.getResourceEntryName(Resources.java:2335)
 	at com.willowtreeapps.hyperion.attr.collectors.ResourceValue.getDisplayValue(ResourceValue.java:21)
 	at com.willowtreeapps.hyperion.attr.ViewAttribute.getDisplayValue(ViewAttribute.java:42)
 	at com.willowtreeapps.hyperion.attr.AttributeDetailView$AttributeViewHolder.onDataChanged(AttributeDetailView.java:164)
 	at com.willowtreeapps.hyperion.attr.AttributeDetailView$AttributeViewHolder.onDataChanged(AttributeDetailView.java:147)
 	at com.willowtreeapps.hyperion.attr.DataViewHolder.bind(DataViewHolder.java:20)
 	at com.willowtreeapps.hyperion.attr.AttributeDetailView$AttributeAdapter.onBindViewHolder(AttributeDetailView.java:118)
 	at com.willowtreeapps.hyperion.attr.AttributeDetailView$AttributeAdapter.onBindViewHolder(AttributeDetailView.java:83)
 	at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7254)
 	at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7337)
 	at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6194)
 	at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6460)
 	at androidx.recyclerview.widget.GapWorker.prefetchPositionWithDeadline(GapWorker.java:288)
 	at androidx.recyclerview.widget.GapWorker.flushTaskWithDeadline(GapWorker.java:345)
 	at androidx.recyclerview.widget.GapWorker.flushTasksWithDeadline(GapWorker.java:361)
 	at androidx.recyclerview.widget.GapWorker.prefetch(GapWorker.java:368)
 	at androidx.recyclerview.widget.GapWorker.run(GapWorker.java:399)
 	at android.os.Handler.handleCallback(Handler.java:942)
 	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:7872)
 	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:936)

The reason of the crash is that view id is always handled as a resource value and resources.getResourceEntryName(id) is called in ResourceValue class after single check id > 0. Ad-hoc solution is to wrap resources.getResourceEntryName(id) with try-catch and return empty string in case of exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions