question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Invalid drawable declarations generated when decompiling Instagram 207.0.0.39.120

See original GitHub issue

Information

  1. Apktool Version (apktool -version) - 2.6.0
  2. Operating System (Mac, Linux, Windows) - Mac
  3. APK From? (Playstore, ROM, Other) - Play Store

Facebook uses some unusual build system for their apps. Resources end up packaged inside the apk in a single folder named r, with some files referenced by more than one entry inside resources.arsc. While apktool does undo most of it correctly, it generates a file res/values/drawables.xml like this:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item type="drawable" name="chalk_brush">R||AQAEH1e24i3A|512|512|160</item>
    <item type="drawable" name="circle">R||AQAAoKYEg-_S|256|255|160</item>
    <item type="drawable" name="direct_dark_mode_inbox_reply_pill_background_gray">@drawable/direct_inbox_reply_pill_background_gray_night</item>
    <!-- more proper resource aliases -->
    <item type="drawable" name="direct_thread_gifs_place_holder_item_shhmode">@drawable/direct_thread_gifs_place_holder_item_night</item>
    <item type="drawable" name="fr_frame">R||AQAAkUF_KkOv|1024|1024|160</item>
    <item type="drawable" name="fr_lut">R||AQAAyPlUeUNj|1024|32|160</item>
    <item type="drawable" name="frbw_frame">R||AQAAk2w7mYkq|1024|1024|160</item>
    <item type="drawable" name="frbw_lut">R||AQAB6iBI8j8n|1024|32|160</item>
    <item type="drawable" name="frbw_overlay">R||AQACuRw-mWCq|1024|1024|160</item>
    <item type="drawable" name="in_call_notif_tv_icon">R||AQAGKjMnng39|120|122|160</item>
    <item type="drawable" name="inline_searchbox_background_shhmode">@drawable/inline_search_box_background_night</item>
    <item type="drawable" name="input_background_shhmode">@drawable/input_background_night</item>
    <item type="drawable" name="instagram_add_filled_24">I1800B7</item>
    <item type="drawable" name="instagram_add_outline_24">I18007B</item>
    <!-- a whole lot more of these nonsensical lines -->
    <item type="drawable" name="ll_font">R||AQACveI2bHlA|160|96|160</item>
    <item type="drawable" name="ll_leaks">R||AQABjmVlm-FX|1024|1024|160</item>
    <item type="drawable" name="ll_lut">R||AQADDu-9mCiw|1024|32|160</item>
    <item type="drawable" name="ll_noise">R||AQADKNuSWsE5|1024|1024|160</item>
    <item type="drawable" name="marker">R||AQABJEwQfEtS|256|256|160</item>
    <item type="drawable" name="media_additional_reactors_circle_shhmode">@drawable/media_additional_reactors_circle_night</item>
    <item type="drawable" name="meme_emphasis">R||AQACINpbVTEL|1301|371|160</item>
    <item type="drawable" name="neon_bulb_asset">R||AQABxh689A9n|256|256|160</item>
    <item type="drawable" name="ps_lut">R||AQABHygJLIb3|1024|32|160</item>
    <item type="drawable" name="radial_asset">R||AQADhGZJhKUF|256|256|160</item>
    <item type="drawable" name="rainbow_brush">R||AQAAeJIP-Nxa|256|256|160</item>
    <item type="drawable" name="textedit_background_error_shhmode">@drawable/textedit_background_error_night</item>
    <item type="drawable" name="textedit_background_shhmode">@drawable/textedit_background_night</item>
    <item type="drawable" name="unified_inbox_message_mask_no_border_shhmode">@drawable/unified_inbox_message_mask_no_border_night</item>
    <item type="drawable" name="unified_inbox_message_mask_shhmode">@drawable/unified_inbox_message_mask_night</item>
    <item type="drawable" name="unified_inbox_my_message_mask_shhmode">@drawable/unified_inbox_my_message_mask_night</item>
    <item type="drawable" name="vhs_glitch_0">R||AQADL3Xyljfu|1024|1024|160</item>
    <item type="drawable" name="vhs_glitch_1">R||AQABaRWCTW4_|1024|1024|160</item>
    <item type="drawable" name="vhs_lut">R||AQABd-1upOoH|1024|128|160</item>
    <item type="drawable" name="APKTOOL_DUMMY_bd" />
    <item type="drawable" name="APKTOOL_DUMMY_105" />
    <item type="drawable" name="APKTOOL_DUMMY_199" />
    <item type="drawable" name="APKTOOL_DUMMY_19a" />
    <item type="drawable" name="APKTOOL_DUMMY_1d4" />
    <item type="drawable" name="APKTOOL_DUMMY_1d5" />
    <!-- and some more of these too — not sure why they're here at all -->
</resources>

Obviously, building this as is results in an app that crashes when it first tries to make use of a resource that decoded incorrectly.

I don’t know Android internals nearly well enough, but might it be that there’s some newer kind of resource reference in resources.arsc, and these are meant to be @drawable/something references?

Stacktrace/Logcat

10-04 00:33:21.495 22922 22922 D AndroidRuntime: Shutting down VM
10-04 00:33:21.497 22922 22922 E AndroidRuntime: FATAL EXCEPTION: main
10-04 00:33:21.497 22922 22922 E AndroidRuntime: Process: com.instagram.android, PID: 22922
10-04 00:33:21.497 22922 22922 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.instagram.android/com.instagram.mainactivity.MainActivity}: android.view.InflateException: Binary XML file line #34: Binary XML file line #35: Error inflating class com.instagram.common.ui.base.IgSimpleImageView
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3654)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3806)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2267)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:107)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:237)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:8167)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #34: Binary XML file line #35: Error inflating class com.instagram.common.ui.base.IgSimpleImageView
10-04 00:33:21.497 22922 22922 E AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #35: Error inflating class com.instagram.common.ui.base.IgSimpleImageView
10-04 00:33:21.497 22922 22922 E AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at java.lang.reflect.Constructor.newInstance0(Native Method)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at android.view.LayoutInflater.createView(LayoutInflater.java:854)
...
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at X.1Zj.A0P(:23)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at androidx.appcompat.app.AppCompatActivity.setContentView(:268435463)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at com.instagram.base.activity.BaseFragmentActivity.onCreate(:14)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at com.instagram.mainactivity.MainActivity.onCreate(:349)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at android.app.Activity.performCreate(Activity.java:7963)
...
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:8167)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: Caused by: android.content.res.Resources$NotFoundException: Drawable com.instagram.android:drawable/instagram_arrow_left_outline_24 with resource ID #0x7f0804ab
10-04 00:33:21.497 22922 22922 E AndroidRuntime: Caused by: android.content.res.Resources$NotFoundException: Drawable com.instagram.android:drawable/instagram_arrow_left_pano_outline_24 with resource ID #0x7f0804ae
10-04 00:33:21.497 22922 22922 E AndroidRuntime: Caused by: android.content.res.Resources$NotFoundException: File I180158 from drawable resource ID #0x7f0804ae
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:999)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:735)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at android.content.res.Resources.getDrawableForDensity(Resources.java:965)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at X.11v.getDrawableForDensity(:65)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at android.content.res.Resources.getDrawable(Resources.java:880)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at X.1Xt.A00(:33)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at X.1Xu.get(:18)
10-04 00:33:21.497 22922 22922 E AndroidRuntime: 	at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:715)
...
10-04 00:33:21.498 22922 22922 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
10-04 00:33:21.498 22922 22922 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
10-04 00:33:21.498 22922 22922 E AndroidRuntime: Caused by: java.io.FileNotFoundException: I180158
10-04 00:33:21.498 22922 22922 E AndroidRuntime: 	at android.content.res.AssetManager.nativeOpenNonAsset(Native Method)
10-04 00:33:21.498 22922 22922 E AndroidRuntime: 	at android.content.res.AssetManager.openNonAsset(AssetManager.java:992)
10-04 00:33:21.498 22922 22922 E AndroidRuntime: 	at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:983)
10-04 00:33:21.498 22922 22922 E AndroidRuntime: 	... 58 more

Steps to Reproduce

  1. apktool d instagram.apk
  2. apktool b instagram

Frameworks

If this APK is from an OEM ROM (Samsung, HTC, LG). Please attach framework files (.apks that live in /system/framework or /system/priv-app)

It is not.

APK

If this APK can be freely shared, please upload/attach a link to it.

https://www.apkmirror.com/apk/instagram/instagram-instagram/instagram-instagram-207-0-0-39-120-release/instagram-207-0-0-39-120-android-apk-download/download/

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? Yes, that’s exactly what I did.
  2. If you are trying to install a modified apk, did you resign it? Yes.
  3. Are you using the latest apktool version? Yes.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
iBotPeachescommented, Mar 9, 2022

I appreciate the research you did as I read my email on this ticket @MartinDupont

1reaction
grishkacommented, Oct 6, 2021

Duplicating here from the chat. I worked around this by decompiling with --no-res, extracting the /r directory from the apk into /unknown in the project, and adding all the files under /r to unknownFiles in apktool.yml. This results in a fully working rebuilt apk.

Downside? I can’t modify the resources. Not that I intended to, anyway. This would most probably work with other Facebook apps (Facebook itself, Messenger, and probably WhatsApp) as well.

p.s. TIL that Android 11 is really picky about apks and requires 4-byte alignment and a v2 signature if you target it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apktool - bytemeta
[BUG] Invalid drawable declarations generated when decompiling Instagram 207.0.0.39.120. Inchworm333. Inchworm333 OPEN · Updated 3 months ago ...
Read more >
杀死provider后metadata下有遗留数据,看着不正常- Apache/Dubbo
This issue has been created since 2022-06-23. ... [BUG] Invalid drawable declarations generated when decompiling Instagram 207.0.0.39.120, 6, 2021-10-03 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found