Apktool
Apktool copied to clipboard
[BUG] Recompilation error: "invalid value for type 'layout'. Expected a reference"
Information
- Apktool Version (
apktool -version) - 2.5.1 - Operating System (Mac, Linux, Windows) - Ubuntu 20
- APK From? (Playstore, ROM, Other) - apkpure.com
Stacktrace/Logcat
bro@local:\~/ig-apk$ **apktool d ig-196-apkpure.apk**
...
...
...
bro@local:~/ig-apk$ **apktool b --use-aapt2 -o out.apk ig-196-apkpure**
I: Using Apktool 2.5.1-eaab72-SNAPSHOT
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether resources has changed...
I: Building resources...
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:12: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:13: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:14: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:15: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:16: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:17: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:18: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:19: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:20: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:21: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:22: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:23: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:24: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:25: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:26: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:27: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:28: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:29: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:30: error: invalid value for type 'layout'. Expected a reference.
W: /home/bro/ig-apk/ig-196-apkpure/res/values-v22/layouts.xml:31: error: invalid value for type 'layout'. Expected a reference.
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_77580703989672702302554212405921978723.tmp, compile, --dir, /home/bro/ig-apk/ig-196-apkpure/res, --legacy, -o, /home/bro/ig-apk/ig-196-apkpure/build/resources.zip]
Sample of layouts.xml:
...
<item type="layout" name="guide_grid_row">L|46188|5C4|BCF2</item>
<item type="layout" name="guide_ufi_bar">L|4674C|F90|E5CC</item>
<item type="layout" name="gumstick">L|476DC|A50|AC5A</item>
...
Steps to Reproduce
apktool d ig-196-apkpure.apkapktool b --use-aapt2 -o out.apk ig-196-apkpure
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)
APK
Questions to ask before submission
- Have you tried
apktool d,apktool bwithout changing anything? yes - Are you using the latest apktool version? yes
I replicate. Logging some info to help for debugging this later.
➜ 2618 aapt d resources Instagram_v196.0.0.32.126_apkpure.com.apk --values | grep 'guide_grid_row'
spec resource 0x7f0c04bc com.instagram.android:layout/guide_grid_row: flags=0x00000400
resource 0x7f0c04bc com.instagram.android:layout/guide_grid_row: t=0x03 d=0x00002781 (s=0x0008 r=0x00)
resource 0x7f0c04bc com.instagram.android:layout/guide_grid_row: t=0x03 d=0x00002174 (s=0x0008 r=0x00)
➜ Instagram_v196.0.0.32.126_apkpure.com grep -r -i 'guide_grid_row' *
Binary file build/resources.zip matches
res/values-v22/layouts.xml: <item type="layout" name="guide_grid_row">L|46188|5C4|BCF2</item>
res/values/layouts.xml: <item type="layout" name="guide_grid_row">L|2AE8F8|590|E594</item>
res/values/public.xml: <public type="layout" name="guide_grid_row" id="0x7f0c04bc" />
Can confirm having the same issue on M1 Mac and Windows. Recompiling the Instagram app.
Any update on this issue? Is there any workaround?
Hey there, just had the same error and steps how I fixed it in my case:
- Run 'apktool empty-framework-dir' command before re-building an app
- Run apktool b -o out.apk ig-196-apkpure (it seems that issue was with --use-aapt2 flag in my case)
it seems that issue was with --use-aapt2 flag
I do confirm, it fixed the latest whatsapp beta compilation errors.
not work for me
from what ive found the file is decompiled correctly and those values are used to retrieve the layout resource from instagram's proprietary resource format (assets/layouts.bin.xz)
source: method(jadx) X.C1Mj.getLayout(int) and X.C24601Mp.A00() from instagram apk version 315.0.0.0.6 alpha (371500513)
the resource format seems to contain axml blocks too source: constructor(jadx) X.C1NA.C1NA(Resources, File)