Search code examples
androidxmlgradleapkcrashlytics

How to find the resource from resource ID found in a crash stack


How do i get the resource name from a resource id: #0x7f07012

I've got this crash and stack trace from Crashlytics:

Caused by android.content.res.Resources$NotFoundException: Unable to find resource ID #0x7f070912
   at android.content.res.ResourcesImpl.getResourceName(ResourcesImpl.java:300)
   at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:987)
   at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:747)
   at android.content.res.Resources.loadDrawable(Resources.java:1071)
   at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:1017)
   at android.content.res.TypedArray.getDrawable(TypedArray.java:991)
   at android.widget.ImageView.<init>(ImageView.java:205)
   at android.widget.ImageView.<init>(ImageView.java:191)

I can see that some resource is causing a crash on some devices but since this log only shows me the resource id i can't really know which resource that is causing the issue. How can i reverse engineer the resource id and find the resource.


Solution

  • You can build an APK file from your project and inspect the APK file.

    1. First build the APK

    build apk

    1. Then open/inspect the built APK using Android Studio

    2. Click on the resrouces.asrsc-file

    3. Take the first 4 chars from the ID 0x7f... .

    4. Look for the same first 4 chars ID while changing resource type in the left menu apk inspect

    5. When you found the correct resource type then look for the last remaining chars from you id.