Apktool: decompiling latest Facebook APK - unsupported res type name for bags. Found: style2

Information

  1. Apktool Version: 2.3.1
  2. Operating System: Linux
  3. APK From: APKMirror (https://www.apkmirror.com/apk/facebook-2/facebook/facebook-157-0-0-38-97-release/facebook-157-0-0-38-97-android-apk-download/)

Stacktrace/Logcat

Very long sequence of "Could not decode file" lines: 

https://pastebin.com/edit/rHKMqygQ

Steps to Reproduce

  1. Any attempt to decompile the official Facebook apk (versions 157 and later)
  2. ./apktool d _in/Facebook_157.0.0.38.97.apk -o _working/Facebook_157.0.0.38.97.apk

Frameworks

If this APK is from an OEM ROM (Samsung, HTC, LG): Nope

APK

If this APK can be freely shared, please upload/attach a link to it: https://www.apkmirror.com/apk/facebook-2/facebook/facebook-157-0-0-38-97-release/facebook-157-0-0-38-97-android-apk-download/

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? issues during decompile/recompile
  3. Are you using the latest apktool version? yes

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 9
  • Comments: 24 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Version 2.4.0 still have problems with the facebook apk. But now it crashes with an exception.

c:\temp>apktool -f d com.facebook.katana-1.apk
I: Using Apktool 2.4.0 on com.facebook.katana-1.apk
I: Loading resource table...
Exception in thread "main" brut.androlib.AndrolibException: unsupported res type name for bags. Found: style2
        at brut.androlib.res.data.value.ResValueFactory.bagFactory(ResValueFactory.java:115)
        at brut.androlib.res.decoder.ARSCDecoder.readComplexEntry(ARSCDecoder.java:350)
        at brut.androlib.res.decoder.ARSCDecoder.readEntryData(ARSCDecoder.java:276)
        at brut.androlib.res.decoder.ARSCDecoder.readTableType(ARSCDecoder.java:252)
        at brut.androlib.res.decoder.ARSCDecoder.readTableTypeSpec(ARSCDecoder.java:175)
        at brut.androlib.res.decoder.ARSCDecoder.readTablePackage(ARSCDecoder.java:131)
        at brut.androlib.res.decoder.ARSCDecoder.readTableHeader(ARSCDecoder.java:82)
        at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:48)
        at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:748)
        at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:67)
        at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:59)
        at brut.androlib.Androlib.getResTable(Androlib.java:68)
        at brut.androlib.ApkDecoder.setTargetSdkVersion(ApkDecoder.java:228)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:118)
        at brut.apktool.Main.cmdDecode(Main.java:167)
        at brut.apktool.Main.main(Main.java:76)```

Hi @iBotPeaches, Is there any update about this issue? I am facing the same problem that it couldn’t decode the resources.

Thanks!

I was able to get around the crash by adding the resource type “style2”.

https://github.com/thejunkjon/Apktool/commit/5f3fc54fd5541926bef9a6af797464997e64fde9

That type doesn’t seem to be documented though so I am not sure the change is correct.

https://android.googlesource.com/platform/frameworks/base/+/master/tools/aapt2/Resource.h#66

This site is able to decompile Facebook App http://apk-deguard.com/. But I didn’t find the file AndroidManifest

Note to self. Look into skipping resource decoding (-r) and look into why that is not working. Context: #1739

If you need only decode apk than quick solution:

brut.androlib.res.data.value.ResValueFactory#ResScalarValue

        //if (ResTypeSpec.RES_TYPE_NAME_STYLES.equals(resTypeName)) {
        if (resTypeName != null && resTypeName.startsWith(ResTypeSpec.RES_TYPE_NAME_STYLES)) {
            return new ResStyleValue(parentVal, items, this);
        }

For me it decodes Facebok apk without errors with resources.

@iBotPeaches it sounds great. Thank you for that. Can you explain to me why some resource folders after decompilation named like drawable2, drawable4-xxhdpi, raw2 and etc.