Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
VadimB95 opened this issue Apr 4, 2023 · 0 comments
Open

Comments

@VadimB95
Copy link

VadimB95 commented Apr 4, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant