Apktool icon indicating copy to clipboard operation
Apktool copied to clipboard

[BUG]If there are two resoureces dirs(/res and /r ) in apk,it will only choose res,but what i really need is "/r".

Open jokerzww opened this issue 4 years ago • 4 comments
trafficstars

Information

  1. Apktool Version (apktool -version) - 2.6.0
  2. Operating System (Mac, Linux, Windows) - mac os big sur 11.1
  3. APK From? (Playstore, ROM, Other) - tiktok.apk

Stacktrace/Logcat

S: Could not decode file, replacing by FALSE value: czv.xml error:brut.directory.PathNotExist: czv.xml S: inDir:brut.directory.ZipRODirectory@4cd4c999 brut.androlib.AndrolibException: brut.directory.PathNotExist: czv.xml at brut.androlib.res.decoder.ResFileDecoder.decode(ResFileDecoder.java:144) at brut.androlib.res.decoder.ResFileDecoder.decode(ResFileDecoder.java:119) at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:247) at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:136) at brut.androlib.ApkDecoder.decode(ApkDecoder.java:111) at brut.apktool.Main.cmdDecode(Main.java:175) at brut.apktool.Main.main(Main.java:79) Caused by: brut.directory.PathNotExist: czv.xml at brut.directory.AbstractDirectory.getFileInput(AbstractDirectory.java:110) at brut.androlib.res.decoder.ResFileDecoder.decode(ResFileDecoder.java:139) ... 6 more

Include stacktrace here

Steps to Reproduce

java -Xmx2048m -jar ./apktool-cli-all.jar d base.apk -o base

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

If this APK can be freely shared, please upload/attach a link to it. adb pull from google play

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? just decode
  3. Are you using the latest apktool version? yes

jokerzww avatar Oct 08 '21 08:10 jokerzww

it use sth like AndResGuard,I try to use the real dir "/r" like this,and add more code to replace writeStartTag to solve this "AndResGuard" image

          private void writeStartTagFixed(XmlPullParser pp) throws XmlPullParserException, IOException, AndrolibException {
                 if (!pp.getFeature (XmlPullParser.FEATURE_REPORT_NAMESPACE_ATTRIBUTES)) {
                    int nsStart = pp.getNamespaceCount(pp.getDepth()-1);
                    int nsEnd = pp.getNamespaceCount(pp.getDepth());
                    for (int i = nsStart; i < nsEnd; i++) {
                        String prefix = pp.getNamespacePrefix(i);
                        String ns = pp.getNamespaceUri(i);
                        setPrefix(prefix, ns);
                    }
                }
                startTag(pp.getNamespace(), pp.getName());

                HashMap<Integer,String> attrMaps = new HashMap<Integer,String>();
                //Gets all attR ids and their corresponding obfuscated names
                AXmlResourceParser arp = (AXmlResourceParser) mParser;
                List<ResResSpec> resResSpecs = arp.getAttrDecoder().getCurrentPackage().listResSpecs();
                for (ResResSpec resResSpec : resResSpecs) {
                    if ("attr".equalsIgnoreCase(resResSpec.getType().getName())) {
                        attrMaps.put(resResSpec.getId().id, resResSpec.getName());
                    }
                }

                for (int i = 0; i < pp.getAttributeCount(); i++) {
                    // current  attr id
                    int id = arp.getAttributeNameResource(i);
                    // If found, attribute is written to the file with an obfuscated name
                    String attr = attrMaps.get(id);
                    attribute
                        (pp.getAttributeNamespace(i),
                            attr == null ? pp.getAttributeName(i) : attr,
                            pp.getAttributeValue(i));
                }
            }

i dont know how to solve "W: Unknown data detected. Skipping: 80 byte(s)", trying to find it work I: Using Apktool 2.6.1-9bdf38-SNAPSHOT on base.apk I: Loading resource table... W: Unknown data detected. Skipping: 80 byte(s) W: Unknown data detected. Skipping: 416 byte(s) W: Unknown data detected. Skipping: 1392 byte(s) W: Unknown data detected. Skipping: 1536 byte(s) W: Unknown data detected. Skipping: 2304 byte(s) W: Unknown data detected. Skipping: 1104 byte(s) I: Decoding AndroidManifest.xml with resources... I: Loading resource table from file: /Users/thejokerw/Library/apktool/framework/1.apk I: Regular manifest package... I: Decoding file-resources... W: Cant find 9patch chunk in file: "bay.9.png". Renaming it to *.png. W: Cant find 9patch chunk in file: "bay.9.png". Renaming it to *.png. W: Cant find 9patch chunk in file: "bay.9.png". Renaming it to *.png. W: Cant find 9patch chunk in file: "bay.9.png". Renaming it to *.png. W: Cant find 9patch chunk in file: "bay.9.png". Renaming it to *.png. W: Cant find 9patch chunk in file: "bay.9.png". Renaming it to *.png. W: Cant find 9patch chunk in file: "bay.9.png". Renaming it to *.png. W: Cant find 9patch chunk in file: "bay.9.png". Renaming it to *.png. W: Cant find 9patch chunk in file: "bay.9.png". Renaming it to *.png. W: Cant find 9patch chunk in file: "bay.9.png". Renaming it to *.png. W: Cant find 9patch chunk in file: "bay.9.png". Renaming it to *.png. W: Cant find 9patch chunk in file: "bay.9.png". Renaming it to *.png. W: Cant find 9patch chunk in file: "bay.9.png". Renaming it to *.png. W: Cant find 9patch chunk in file: "bay.9.png". Renaming it to *.png. W: Cant find 9patch chunk in file: "bay.9.png". Renaming it to *.png. W: Cant find 9patch chunk in file: "bay.9.png". Renaming it to *.png. W: Cant find 9patch chunk in file: "bay.9.png". Renaming it to *.png. I: Decoding values / XMLs... I: Baksmaling classes.dex... I: Baksmaling classes10.dex... I: Baksmaling classes11.dex... I: Baksmaling classes12.dex... I: Baksmaling classes13.dex... I: Baksmaling classes14.dex... I: Baksmaling classes15.dex... I: Baksmaling classes16.dex... I: Baksmaling classes17.dex... I: Baksmaling classes18.dex... I: Baksmaling classes19.dex... I: Baksmaling classes2.dex... I: Baksmaling classes3.dex... I: Baksmaling classes4.dex... I: Baksmaling classes5.dex... I: Baksmaling classes6.dex... I: Baksmaling classes7.dex... I: Baksmaling classes8.dex... I: Baksmaling classes9.dex... I: Copying assets and libs... I: Copying unknown files... I: Copying original files... I: Copying META-INF/services directory

jokerzww avatar Oct 08 '21 08:10 jokerzww

now i use this ,and I don't know what to do next,”base3“ is result after above opeartions

java -Xmx8192m -jar ./apktool-cli-all.jar b --use-aapt2 base3 -o base3.apk

I: Using Apktool 2.6.1-9bdf38-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 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 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 sources has changed... I: Checking whether resources has changed... I: Building resources... W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f0f16.xml:2: error: duplicate attribute. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f0f16.xml: error: file failed to compile. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f1557.xml:2: error: duplicate attribute. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f1557.xml: error: file failed to compile. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f155a.xml:2: error: duplicate attribute. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f155a.xml: error: file failed to compile. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f1726.xml:2: error: duplicate attribute. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f1726.xml: error: file failed to compile. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f1727.xml:2: error: duplicate attribute. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f1727.xml: error: file failed to compile. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f175c.xml:2: error: duplicate attribute. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f175c.xml: error: file failed to compile. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f175d.xml:2: error: duplicate attribute. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f175d.xml: error: file failed to compile. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f175f.xml:2: error: duplicate attribute. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f175f.xml: error: file failed to compile. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f17e3.xml:2: error: duplicate attribute. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f17e3.xml: error: file failed to compile. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f17fe.xml:2: error: duplicate attribute. W: /Users/thejokerw/Documents/reverse_workspace/base3/res/layout-land/APKTOOL_DUPLICATE_layout_0x7f0f17fe.xml: error: file failed to compile. brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/brut_util_Jar_22085935557242804195046845076295642459.tmp, compile, --dir, /Users/thejokerw/Documents/reverse_workspace/base3/res, --legacy, -o, /Users/thejokerw/Documents/reverse_workspace/base3/build/resources.zip]

jokerzww avatar Oct 08 '21 08:10 jokerzww

Quite a lot of information here, but I would urge you to push up a PR if you feel you've encountered something that can be resolved. Have not had time to dig into this yet.

iBotPeaches avatar Oct 08 '21 10:10 iBotPeaches

Quite a lot of information here, but I would urge you to push up a PR if you feel you've encountered something that can be resolved. Have not had time to dig into this yet.

ok,i will dig it up

jokerzww avatar Oct 08 '21 12:10 jokerzww