Open weary-adventurer opened 11 months ago
As you mention the icon becoming corrupted. I believe this may resolve it - https://github.com/iBotPeaches/Apktool/pull/3360
I'm testing this out on another ticket and no longer seeing icon corruption - just haven't built mac binaries yet, so its not mergable.
Same error using aapt2_64.exe
from here:
$ apktool b --aapt aapt2_64.exe _unpacked -o _packed\1_unsigned.apk
I: Using Apktool 2.8.1
I: Copying X:\test\.\_unpacked classes.dex file...
[Fatal Error] :1:1: Content is not allowed in prolog.
I: Checking whether resources has changed...
I: Building AndroidManifest.xml...
W: X:\test\.\_unpacked\AndroidManifest.xml:1: error: not well-formed (invalid token).
W: Parse AndroidManifest.xml failed, treat it as raw file.
I: Copying raw AndroidManifest.xml...
I: Building apk file...
I: Copying unknown files/dir...
I: Built apk into: X:\test\.\_packed\1_unsigned.apk
Same error using
aapt2_64.exe
from here:
aapt isn't invoked at that point. I'd hold till next release for the moment unless you want to really mess with bleeding edge builds and fresh aapts.
I can test it pretty quickly so I don't see why not - if you have an apktool.jar
of the new build I'll just swap it out and rerun the command.
I can test it pretty quickly so I don't see why not - if you have an
apktool.jar
of the new build I'll just swap it out and rerun the command.
All master commits trigger a build as an attachment https://github.com/iBotPeaches/Apktool/actions/runs/6391710817
It's bleeding edge master builds.
Same problem:
$ apktool b --use-aapt2 _unpacked -o _packed\1_unsigned.apk
I: Using Apktool v2.8.1-77-448440b5-SNAPSHOT
I: Copying X:\test\.\_unpacked classes.dex file...
[Fatal Error] :1:1: Content is not allowed in prolog.
I: Checking whether resources has changed...
I: Building AndroidManifest.xml...
W: X:\test\.\_unpacked\AndroidManifest.xml:1: error: not well-formed (invalid token).
W: Parse AndroidManifest.xml failed, treat it as raw file.
I: Copying raw AndroidManifest.xml...
I: Building apk file...
I: Copying unknown files/dir...
I: Built apk into: X:\test\.\_packed\1_unsigned.apk
Okay to the backlog it goes. Sorry! Will focus after I finish up 2.9.x, thanks for testing.
I'm having similar issue as the OP, having installed the latest framework-res.apk (matches with compileSdkVersion) pulled from emulator and it could not build, without any changes.
I: Using Apktool 2.8.1
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: <generated>:0: error: Resource entry @null is already defined.
W: <generated>:0: Originally defined here.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:9: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:15: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:20: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:39: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:47: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:106: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:112: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:163: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:189: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:196: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:210: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:229: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:238: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:297: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:323: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:347: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:380: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:384: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:388: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:392: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:396: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:453: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:522: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:560: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:581: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:590: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:701: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:723: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:743: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:748: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:754: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:760: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:807: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:815: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:838: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:846: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:949: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:982: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:986: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:995: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:1102: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:1112: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:1241: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:1248: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:1253: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:1343: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:1360: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:1368: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:1377: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:1461: error: Error: No resource found that matches the given name: id '@null'.
W:
W: /some/place/on/my/pc/res/values/attrs.xml:1515: error: Error: No resource found that matches the given name: id '@null'.
W:
brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/var/folders/xm/qztxy4kj2z7fj225d95_rdy80000gn/T/brut_util_Jar_15258914466107107889730254320349036517.tmp, p, --forced-package-id, 127, --version-code, 730, --version-name, 0.15.2, --no-version-vectors, -F, /var/folders/xm/qztxy4kj2z7fj225d95_rdy80000gn/T/APKTOOL15957171665988370597.tmp, -e, /var/folders/xm/qztxy4kj2z7fj225d95_rdy80000gn/T/APKTOOL14549013480625325211.tmp, -0, arsc, -I, /Users/vpz/Library/apktool/framework/1.apk, -S, /some/place/on/my/pc/res, -M, /some/place/on/my/pc/AndroidManifest.xml]
I also tried using the build from master
via Docker, fails on building resources with a weird error.
% docker run --rm -it --platform=linux/amd64 -v .:/app -w /app ghcr.io/ibotpeaches/apktool:master sh
Unable to find image 'ghcr.io/ibotpeaches/apktool:master' locally
master: Pulling from ibotpeaches/apktool
707e32e9fc56: Pull complete
1ed42af34167: Pull complete
4014d94a7eba: Pull complete
14869f03ca47: Pull complete
66aa4b4e2abb: Pull complete
497d3d8587e8: Pull complete
9c9c5a403682: Pull complete
Digest: sha256:fa76918b53454719ca277dee0f1623d090c6220311ad6630d7b4142b51744ea6
Status: Downloaded newer image for ghcr.io/ibotpeaches/apktool:master
# apktool if framework-res.apk
I: Framework installed to: /root/.local/share/apktool/framework/1.apk
# apktool d sourceapp.apk -o targetapp
I: Using Apktool 2.8.2-dirty on sourceapp.apk
I: Loading resource table...
I: Decoding file-resources...
I: Loading resource table from file: /root/.local/share/apktool/framework/1.apk
I: Decoding values */* XMLs...
I: Decoding AndroidManifest.xml with resources...
I: Regular manifest package...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
I: Copying META-INF/services directory
# apktool b targetapp -o targetapp.apk
I: Using Apktool 2.8.2-dirty
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
This command is not for general use and should only be run as the result of a call to
ProcessBuilder.start() or Runtime.exec() in a java application
brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec: [/tmp/brut_util_Jar_47934858844575977317641301982171960779.tmp, compile, --dir, /app/targetapp/res, --legacy, -o, /app/targetapp/build/resources.zip]
@vaibhavpandeyvpz docker container is only a few days old. Haven't worked out all the kinks with it, then Android 14 dropped. So it's on the back burner.
I just tried taking out the /usr/local/bin/apktool.jar
from the container and run it on M2 Pro machine natively, get different errors. Please see below:
% java -jar apktool.jar d sourceapp.apk -o targetapp
I: Using Apktool 2.8.2-dirty on sourceapp.apk
I: Loading resource table...
I: Decoding file-resources...
I: Loading resource table from file: /heavenly/place/Library/apktool/framework/1.apk
I: Decoding values */* XMLs...
I: Decoding AndroidManifest.xml with resources...
I: Regular manifest package...
I: Baksmaling classes.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
I: Copying META-INF/services directory
% java -jar apktool.jar b targetapp -o targetapp.apk
I: Using Apktool 2.8.2-dirty
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether resources has changed...
I: Building resources...
W: /heavenly/place/targetapp/res/animator/2130837504.xml:4: error: not well-formed (invalid token).
W: /heavenly/place/targetapp/res/animator/2130837504.xml: error: file failed to compile.
W: /heavenly/place/targetapp/res/animator/2130837519.xml:4: error: not well-formed (invalid token).
W: /heavenly/place/targetapp/res/animator/2130837519.xml: error: file failed to compile.
W: /heavenly/place/targetapp/res/color/2131099847.xml:5: error: not well-formed (invalid token).
W: /heavenly/place/targetapp/res/color/2131099847.xml: error: file failed to compile.
W: /heavenly/place/targetapp/res/color/2131099848.xml:5: error: not well-formed (invalid token).
W: /heavenly/place/targetapp/res/color/2131099848.xml: error: file failed to compile.
W: /heavenly/place/targetapp/res/layout-land/2131492956.xml:2: error: not well-formed (invalid token).
W: /heavenly/place/targetapp/res/layout-land/2131492956.xml: error: file failed to compile.
W: /heavenly/place/targetapp/res/layout-land/2131492963.xml:4: error: not well-formed (invalid token).
W: /heavenly/place/targetapp/res/layout-land/2131492963.xml: error: file failed to compile.
W: /heavenly/place/targetapp/res/layout-ldrtl/2131492960.xml:2: error: not well-formed (invalid token).
W: /heavenly/place/targetapp/res/layout-ldrtl/2131492960.xml: error: file failed to compile.
W: /heavenly/place/targetapp/res/layout/2131492867.xml:2: error: not well-formed (invalid token).
W: /heavenly/place/targetapp/res/layout/2131492867.xml: error: file failed to compile.
W: /heavenly/place/targetapp/res/layout/2131492869.xml:2: error: not well-formed (invalid token).
W: /heavenly/place/targetapp/res/layout/2131492869.xml: error: file failed to compile.
W: /heavenly/place/targetapp/res/layout/2131492887.xml:6: error: not well-formed (invalid token).
W: /heavenly/place/targetapp/res/layout/2131492887.xml: error: file failed to compile.
brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/var/folders/xm/qztxy4kj2z7fj225d95_rdy80000gn/T/brut_util_Jar_74481588292727980021117246174335452358.tmp, compile, --dir, /heavenly/place/targetapp/res, --legacy, -o, /heavenly/place/targetapp/build/resources.zip]
I wanted to replace the package name so for me a blind string replace in all files was enough.
Instead of apktool d --no-res --no-src
I'm using this:
7z x -ssc -o".\unpacked" "target.apk"
pushd ".\unpacked"
for /r %%f in (*.*) do (
rem replace ascii and utf16le of string in all files
binaryreplace -s com.android.chrome -r com.android.chr117 -f %%f
)
for /r %%f in (*.dex) do (
rem file[12..32] = sha1(file[32..])
rem file[8..12] = adler32(file[12..])
dexchecksum %%f
)
popd
7z a -tzip -ssc -mx=0 "1_unsigned.apk" ".\unpacked\*"
zipalign -p -f 4 "1_unsigned.apk" "2_zipaligned.apk"
apksigner sign --key ".\key" --cert ".\cert" --out "3_signed.apk" "2_zipaligned.apk"
Note: You must have case sensitivity flag enabled for the directory you're extracting the APK to.
On Windows files are case-insensitive, so different resources like "-b.xml" and "-B.xml" will collide when extracted.
Enable case-sensitivity for 1 folder with fsutil
: (Windows 10+)
fsutil file setCaseSensitiveInfo .\unpacked enable
That’s clever. I’ll check this soon and let you know if it works for me too. Me too only want to change the package name. Thanks!
Oh, these are for Command Prompt. I'm on Mac 😬
Took a look at this again - the warning during compilation is because there is no resources.arsc
for this logic to detect if resource disassembly was enabled or not. Seems harmless, but annoying.
No good way to resolve because the flag is used during disassembly and not persisted towards assembly. Relying on the resources.arsc
was a good method until split apks came out.
For the crash issues - I can't investigate. Don't have anything rooted at the moment to support reinstalling system apps like Chrome.
So I'll place this into backlog.
Information
apktool -version
) - 2.8.1java --version
) - openjdk 17.0.7 2023-04-18Stacktrace/Logcat
When unpacking a split APK without any resource disassembly, the packing fails:
The APK gets built and can be installed:
The app appears inside the launcher without an icon:
If you run it, it crashes with this stacktrace from logcat:
Steps to Reproduce
apktool d --no-res --no-src split_chrome.apk -f -o _unpacked
apktool b --use-aapt2 _unpacked -o _packed\1_unsigned.apk
I'm trying these steps on 3 files of a base APK and splits. The error only happens when building an extracted split_ apk:
APK
If this APK can be freely shared, please upload/attach a link to it. chrome_117.zip
Questions to ask before submission
apktool d
,apktool b
without changing anything? Yes