Manifest not reencoding (corrupt XML binary file?) causing error signing/installing
See original GitHub issueInformation
- Apktool Version (
apktool -version
) - 2.4.1 - Operating System (Mac, Linux, Windows) - macOS
- APK From? (Playstore, ROM, Other) - Other
Stacktrace/Logcat
Decoding with -rs --force-manifest
I: Using Apktool 2.4.1 on 67f32da161bc63a8ac5a07c1df819e63.apk
I: Copying raw resources...
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /Users/aptmas/Library/apktool/framework/1.apk
I: Regular manifest package...
I: Copying raw classes.dex file...
I: Copying raw classes3.dex file...
I: Copying raw classes5.dex file...
I: Copying raw classes6.dex file...
I: Copying raw classes4.dex file...
I: Copying raw classes2.dex file...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
Encoding without flags
I: Using Apktool 2.4.1
I: Copying 67f32da161bc63a8ac5a07c1df819e63 classes.dex file...
I: Copying 67f32da161bc63a8ac5a07c1df819e63 classes3.dex file...
I: Copying 67f32da161bc63a8ac5a07c1df819e63 classes2.dex file...
I: Copying 67f32da161bc63a8ac5a07c1df819e63 classes6.dex file...
I: Copying 67f32da161bc63a8ac5a07c1df819e63 classes5.dex file...
I: Copying 67f32da161bc63a8ac5a07c1df819e63 classes4.dex file...
I: Checking whether resources has changed...
I: Copying raw resources...
I: Copying libs... (/lib)
I: Building apk file...
I: Copying unknown files/dir...
I: Built apk...
ApkSigner
Exception in thread "main" com.android.apksig.apk.MinSdkVersionException: Failed to determine APK's minimum supported platform version. Use --min-sdk-version to override
at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:372)
at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:123)
at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:84)
Caused by: com.android.apksig.apk.MinSdkVersionException: Unable to determine APK's minimum supported Android platform version: malformed binary resource: AndroidManifest.xml
at com.android.apksig.apk.ApkUtils.getMinSdkVersionFromBinaryAndroidManifest(ApkUtils.java:384)
at com.android.apksig.ApkSigner.getMinSdkVersionFromApk(ApkSigner.java:857)
at com.android.apksig.ApkSigner.sign(ApkSigner.java:260)
at com.android.apksig.ApkSigner.sign(ApkSigner.java:193)
at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:366)
... 2 more
Caused by: com.android.apksig.internal.apk.AndroidBinXmlParser$XmlParserException: No XML chunk in file
at com.android.apksig.internal.apk.AndroidBinXmlParser.<init>(AndroidBinXmlParser.java:101)
at com.android.apksig.apk.ApkUtils.getMinSdkVersionFromBinaryAndroidManifest(ApkUtils.java:345)
... 6 more
Installation
INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: Failed to parse /data/app/vmdl1094509404.tmp/base.apk: Corrupt XML binary file
Steps to Reproduce
- Use apktool to decode APK with -rs --force-manifest (no error) - log above
- Use apktool to encode APK without any changes (no error) - log above
- Try to sign/install APK and get the errors above
I have also tried to do it without flags but while it decodes correctly, when it’s building it’ll show errors related to “No resource identifier found for attribute” eventually failing for:
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/var/folders/nf/t6_29zc50pb_lw5ww_p74rym0000gp/T/brut_util_Jar_6758575029498112036.tmp, p, --forced-package-id, 127, --min-sdk-version, 19, --target-sdk-version, 28, --version-code, 4226, --version-name, 1.9.13c, --no-version-vectors, -F, /var/folders/nf/t6_29zc50pb_lw5ww_p74rym0000gp/T/APKTOOL6277513217225256484.tmp, -e, /var/folders/nf/t6_29zc50pb_lw5ww_p74rym0000gp/T/APKTOOL7421589631204875490.tmp, -0, arsc, -I, /Users/x/Library/apktool/framework/1.apk, -S, /Users/x/Desktop/!/apktools/67f32da161bc63a8ac5a07c1df819e63/res, -M, /Users/x/Desktop/!/apktools/67f32da161bc63a8ac5a07c1df819e63/AndroidManifest.xml]
By looking inside the APK I have noticed the AndroidManifest.xml isn’t getting reencoded even if it builds successfully, so perhaps this is why the apksigner complains about malformed XML?
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Merged AndroidManifest only contains the Library content
I have checked APK analyzer in AndroidStudio, and I found that AndroidManifest.xml not contains any code related to my application, it only ...
Read more >"Corrupt XML binary file" error when adding a PNG to res ...
I'm seeing an odd error when adding a PNG file to the res/drawable ... Corrupt XML binary file ... The activity name in...
Read more >Re-encoding corrupt files using iTunes - Serato Support
Open the files window list and click 'Convert' - 'Create MP3 Version' and iTunes will do the rest. Please note that this will...
Read more >error in manifest or policy file invalid xml syntax
I checked the event log and found an error in manifest or policy files at line 0 invalid xml syntax (completely blank what...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I tried building the repo and reproducing this bug running apktool from the jar file. Unfortunately, it was not fixed.
My understanding of the problem is that the AndroidManifest.xml is not converted back to AXML by apktool when building after a decompile with
--force-manifest
. This can be confirmed by unzipping the corrupted APK and checking AndroidManifest.xml.Does that change your opinion about this issue? Thank you and sorry if I’m misunderstanding the scope of apktool.
omg… i was experiencing the same problems…