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

[BUG]Exception in thread "main" brut.androlib.AndrolibException: Could not decode arsc file #2824

Closed
dishcheng opened this issue May 27, 2022 · 10 comments · Fixed by #3252
Closed
Labels
Milestone

Comments

@dishcheng
Copy link

dishcheng commented May 27, 2022

Information

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

Stacktrace/Logcat

apktool d -f -s xxxx.apk

I: Using Apktool 2.6.1 on xxxx.apk
I: Loading resource table...
Exception in thread "main" brut.androlib.AndrolibException: Could not decode arsc file
	at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:55)
	at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:783)
	at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:64)
	at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:56)
	at brut.androlib.Androlib.getResTable(Androlib.java:70)
	at brut.androlib.ApkDecoder.getResTable(ApkDecoder.java:247)
	at brut.androlib.ApkDecoder.decode(ApkDecoder.java:109)
	at brut.apktool.Main.cmdDecode(Main.java:175)
	at brut.apktool.Main.main(Main.java:79)
Caused by: java.io.IOException: Expected: 0x00000008, got: 0x00000003
	at brut.util.ExtDataInput.skipCheckShort(ExtDataInput.java:53)
	at brut.androlib.res.decoder.ARSCDecoder.readValue(ARSCDecoder.java:360)
	at brut.androlib.res.decoder.ARSCDecoder.readEntryData(ARSCDecoder.java:285)
	at brut.androlib.res.decoder.ARSCDecoder.readTableType(ARSCDecoder.java:261)
	at brut.androlib.res.decoder.ARSCDecoder.readTableTypeSpec(ARSCDecoder.java:184)
	at brut.androlib.res.decoder.ARSCDecoder.readTablePackage(ARSCDecoder.java:135)
	at brut.androlib.res.decoder.ARSCDecoder.readTableHeader(ARSCDecoder.java:84)
	at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:50)
	... 8 more

Steps to Reproduce

  1. apktool

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

  1. Have you tried apktool d, apktool b without changing anything? yes
  2. If you are trying to install a modified apk, did you resign it? no
  3. Are you using the latest apktool version? yes
@dishcheng
Copy link
Author

dishcheng commented May 27, 2022

...

@iBotPeaches
Copy link
Owner

Confirmed. Marking as bug. Must be a new iteration of sparse resources or a new type.

@sys0613
Copy link

sys0613 commented Jul 30, 2022

@dishcheng
Copy link
Author

https://download.moutai519.com.cn/mt-download/app/v1/imoutai.apk
@dishcheng 请问解决了么,兄弟。

沒辦法

@sys0613
Copy link

sys0613 commented Jul 30, 2022

@dishcheng 我刚开始弄,寻思研究研究,jar拿到了,没资源文件不行啊。刚用2.6.0试试,发现还是不行。再往前退版本,你试了么。是因为没有框架文件么?

@sys0613
Copy link

sys0613 commented Jul 30, 2022

@iBotPeaches I have the same problem,How should I solve it,thanks

@AAA12702
Copy link

AAA12702 commented Jan 5, 2023

Same issue even with version 2.7

@eacmen
Copy link

eacmen commented Jun 4, 2023

In case it helps same stack trace also occurs on TTlock apk: https://m.apkpure.com/ttlock/com.tongtongsuo.app

@iBotPeaches
Copy link
Owner

An interesting technique. It seems we have a duplicate resource at the end of the chunk with no corresponding value. Its quite small and Apktool made an assumption that it would always have a ResValue if a non-empty specId was encountered.

      [ResTable_entry] id: 0x0596 name: zoom keyIndex: 5177 size: 8 flags: 0x0004
        [Res_value] size: 8 dataType: 0x12 data: 0x00000000 ((id))
      [ResTable_entry] id: 0x0597 name: zoom keyIndex: 5177 size: 8 flags: 0x0004
        [Res_value] size: 3 dataType: 0x12 data: 0x00000000 ((id))

You can see the last style is only size 3. So we can design a patch to skip value reading and return null if the size is small.

@iBotPeaches
Copy link
Owner

➜  2824 apktool d imoutai.apk -s -f
I: Using Apktool v2.8.1-54-7405e504-SNAPSHOT on imoutai.apk
I: Loading resource table...
W: Unknown data detected. Skipping: 6 byte(s)
I: Decoding file-resources...
I: Loading resource table from file: /home/ibotpeaches/.local/share/apktool/framework/1.apk
I: Decoding values */* XMLs...
I: Decoding AndroidManifest.xml with resources...
I: Regular manifest package...
I: Copying raw classes.dex file...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
I: Copying META-INF/services directory
➜  2824 vim imoutai/AndroidManifest.xml 
➜  2824 apktool b imoutai --use-aapt2
I: Using Apktool v2.8.1-54-7405e504-SNAPSHOT
I: Copying imoutai classes.dex file...
I: Checking whether resources has changed...
I: Building resources...
I: Copying libs... (/lib)
I: Copying libs... (/kotlin)
I: Copying libs... (/META-INF/services)
I: Building apk file...
I: Copying unknown files/dir...
I: Built apk into: imoutai/dist/imoutai.apk
➜  2824 

PR above will close this once merged.

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

Successfully merging a pull request may close this issue.

5 participants