最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Can't root cause an Android Resource Not Found Exception - Stack Overflow

programmeradmin0浏览0评论

I'm having a hard time resolving a Resource ID Exception for a dimension in an App I'm working on. I can not reproduce it locally, but a lot of users are seeing it. Interestingly, it only seems to be happening on Android 15, and it seems to happen more in some countries than others.

Crash Example

crashmessage=Resource ID #0x7f070989, stacktrace=android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:269), android.content.res.Resources.getDimensionPixelSize(Resources.java:850), com.images.CarouselImageResolver.getImageDataForCover(ImageResolver.kt:72)

Looking at the code, this ID is a dimension and is loaded like this

val sizeSpec =
                ImageSizeSpec(
                    mContext.resources.getDimensionPixelSize(dimen.standard_carousel_card_width),
                    mContext.resources.getDimensionPixelSize(dimen.standard_carousel_card_height)
                )

Examining the APK, and looking at the code, the dimen resides in an Imported UI package, where it's declared like this:

<dimen name="standard_carousel_card_height">@dimen/title_card_standard_16_9_height</dimen>

title_card_standard_16_9_height has a declaration in res/values/styles.xml of

<dimen name="title_card_standard_16_9_height">111dp</dimen>

and in res/values-sw-600dp/styles.xml of

<dimen name="title_card_standard_16_9_height">180dp</dimen>

The mContext.resources we're using is just the activity and passed into the CarouselImageResolver during construction.

I'm assuming there must be something wrong with the context where the dimension is unavailable in some cases, but again I havent been able to replicate this issue, and confirmed in the APK dump that these values do have a base declaration so shouldn't be missing.

This is not the only Resource ID having this issue, but it is the most common. Hoping someone might have some idea of what the issue is/further debug steps.

Thanks in advance

发布评论

评论列表(0)

  1. 暂无评论