iBotPeaches / Apktool

A tool for reverse engineering Android apk files

Home Page:https://apktool.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Facebook: expected element name 'view' and not 'View'

ddxv opened this issue · comments

Information

  1. Apktool Version (apktool -version) -2.9.3
  2. Operating System (Mac, Linux, Windows) - Ubuntu 23.10 / 22.04
  3. APK From? (Playstore, ROM, Other) - https://apkpure.net/facebook/com.facebook.katana/download 450.0.0.2.110
  4. Java Version (java --version) -
Ubuntu 23.10
openjdk 17.0.9 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+9-Ubuntu-123.10)
OpenJDK 64-Bit Server VM (build 17.0.9+9-Ubuntu-123.10, mixed mode, sharing)
Ubuntu 22.04
openjdk 11.0.21 2023-10-17
OpenJDK Runtime Environment (build 11.0.21+9-post-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 11.0.21+9-post-Ubuntu-0ubuntu122.04, mixed mode, sharing)

Stacktrace/Logcat

I: Loading resource table from file: /home/james/.local/share/apktool/framework/1.apk
Exception in thread "main" java.lang.IllegalArgumentException: expected element name 'view' and not 'View'
        at org.xmlpull.renamed.MXSerializer.endTag(MXSerializer.java:708)
        at org.xmlpull.v1.wrapper.classic.XmlSerializerDelegate.endTag(XmlSerializerDelegate.java:124)
        at org.xmlpull.v1.wrapper.classic.StaticXmlSerializerWrapper.event(StaticXmlSerializerWrapper.java:215)
        at brut.androlib.res.decoder.XmlPullStreamDecoder$1.event(XmlPullStreamDecoder.java:78)
        at brut.androlib.res.decoder.XmlPullStreamDecoder.decode(XmlPullStreamDecoder.java:137)
        at brut.androlib.res.decoder.ResStreamDecoderContainer.decode(ResStreamDecoderContainer.java:28)
        at brut.androlib.res.decoder.ResFileDecoder.decode(ResFileDecoder.java:153)
        at brut.androlib.res.decoder.ResFileDecoder.decode(ResFileDecoder.java:133)
        at brut.androlib.res.ResourcesDecoder.decodeResources(ResourcesDecoder.java:172)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:104)
        at brut.apktool.Main.cmdDecode(Main.java:217)
        at brut.apktool.Main.main(Main.java:92)

Steps to Reproduce

  1. apktool d com.facebook.katana

Interesting. I don't think we can safely lower all tags, so we could probably normalize or relax the check on MXSerializer.

Of course it wouldn't be that easy. I thought this was just a case difference, but that leads to a new error.

Exception in thread "main" java.lang.IllegalArgumentException: expected element name 'view' and not 'ViewStub'

Started a draft. Looks like Facebook has grown from just style.2 type naming.

W: invalid resource directory name: /media/ibotpeaches/AOSP/Apktool/3512/3512/res raw.2
W: invalid resource directory name: /media/ibotpeaches/AOSP/Apktool/3512/3512/res drawable.4-xhdpi
W: invalid resource directory name: /media/ibotpeaches/AOSP/Apktool/3512/3512/res drawable.5-mdpi
W: invalid resource directory name: /media/ibotpeaches/AOSP/Apktool/3512/3512/res navigation
W: invalid resource directory name: /media/ibotpeaches/AOSP/Apktool/3512/3512/res drawable.3
W: invalid resource directory name: /media/ibotpeaches/AOSP/Apktool/3512/3512/res drawable.2-xxhdpi
W: invalid resource directory name: /media/ibotpeaches/AOSP/Apktool/3512/3512/res layout.2

Is your goal here only disassembly? Can't promise any success with rebuild, but the patch I have now at least disassembles properly.

@iBotPeaches Thanks for the help. Yes, ultimately I am only disassembling to get the final AndroidManifest.xml and for a pretty low level need, so no worries if this turned out to be more than it seemed. I just wanted to report the issue if it helps.

Sounds good - I'll merge something shortly to repair disassembly.

➜  3512 apktool d 3512.apk -f -s
I: Using Apktool v2.9.2-21-b5c44028-SNAPSHOT on 3512.apk with 8 thread(s).
I: Copying raw classes.dex file...
I: Copying raw classes10.dex file...
I: Copying raw classes11.dex file...
I: Copying raw classes12.dex file...
I: Copying raw classes13.dex file...
I: Copying raw classes14.dex file...
I: Copying raw classes2.dex file...
I: Copying raw classes3.dex file...
I: Copying raw classes4.dex file...
I: Copying raw classes5.dex file...
I: Copying raw classes6.dex file...
I: Copying raw classes7.dex file...
I: Copying raw classes8.dex file...
I: Copying raw classes9.dex file...
I: Loading resource table...
W: End of chunk hit. Skipping remaining entries (4027) in type: attr
W: End of chunk hit. Skipping remaining entries (10236) in type: id
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 assets and libs...
I: Copying unknown files...
I: Copying original files...
➜  3512