MERGE APK Failed
Closed this issue · 9 comments
Describe the bug
MERGE APK Failed
To Reproduce
Steps to reproduce the behavior:
- Used version '1.3.9'
- Operating system 'windows'
00.005 I: [MERGE] Searching apk files ...
00.005 I: [MERGE] Found apk files: 3
00.065 I: [MERGE] Found modules: 3
00.129 I: [MERGE] Merging: com.GencSadiku.CarSimOpenWorld
00.131 I: [MERGE] Added [com.GencSadiku.CarSimOpenWorld] classes.dex -> classes.dex
00.131 I: [MERGE] Added [com.GencSadiku.CarSimOpenWorld] classes2.dex -> classes2.dex
00.215 I: [MERGE] Merging: UnityDataAssetPack
00.220 I: [MERGE] Merging: config.arm64_v8a
00.232 I: [MERGE] Sanitizing manifest ...
00.233 I: [MERGE] Removed-attribute : @0x0101064e
00.234 I: [MERGE] Removed-attribute : @0x0101064f
00.234 I: [MERGE] Removed-attribute : extractNativeLibs
00.234 I: [MERGE] Removed-attribute : isSplitRequired
00.235 I: [MERGE] Removed-element : name="com.android.vending.splits.required"
00.235 I: [MERGE] Removed-element : name="com.android.stamp.source"
00.235 I: [MERGE] Removed-element : name="com.android.stamp.type"
00.237 I: [MERGE] Removed-table-entry : res/xml/splits0.xml
00.237 I: [MERGE] Removed-element : name="com.android.vending.splits"
00.237 I: [MERGE] Removed-element : name="com.android.vending.derived.apk.id"
Exception in thread "main" java.lang.NullPointerException
at com.reandroid.arsc.chunk.xml.ResXmlElement.removeUnusedNamespaces(ResXmlElement.java:306)
at com.reandroid.arsc.chunk.xml.ResXmlDocument.removeUnusedNamespaces(ResXmlDocument.java:150)
at com.reandroid.arsc.chunk.xml.ResXmlDocument.refreshFull(ResXmlDocument.java:170)
at com.reandroid.apk.ApkModule.refreshManifest(ApkModule.java:130)
at com.reandroid.apkeditor.merge.Merger.run(Merger.java:87)
at com.reandroid.apkeditor.merge.Merger.execute(Merger.java:235)
at com.reandroid.apkeditor.Main.execute(Main.java:89)
at com.reandroid.apkeditor.Main.execute(Main.java:64)
at com.reandroid.apkeditor.Main.main(Main.java:36)
Used apk file
com.GencSadiku.CarSimOpenWorld
Additional context
Add any other context about the problem here.
is my java version too lower,use jdk17 is working
@c01ns
You shouldn't close this, it is serious issue.
This error should not happen at any java version and platforms.
Reopening this and try to fix it.
Similar error happens while using Tumblr APKM v35.8.0.110 from https://www.apkmirror.com/apk/tumblr-inc/tumblr/tumblr-35-8-0-110-release/tumblr-fandom-art-chaos-35-8-0-110-android-apk-download/
@c01ns @SubZero5
Please confirm 796cc8d fixes this issue,
Jar is available at action run 10616226207
I am trying to shove the created APK file to ReVanced Manager but still giving errors on Tumblr v36.0.0.111
And here it's error log:
- Logs
Reading APK
Decoding app manifest
Loading patches
Merging integrations
Executing patches
Applied 5 patches
Compiling patched dex files
Compiled 8 dex files
Aligning APK
Signing APK
An error occurred:
com.android.apksig.apk.MinSdkVersionException: Failed to determine APK's minimum supported Android platform version
at com.android.apksig.ApkSigner.getMinSdkVersionFromApk(Unknown Source:16)
at com.android.apksig.ApkSigner.sign(SourceFile:0)
at com.android.apksig.ApkSigner.sign(SourceFile:0)
at app.revanced.library.ApkSigner$Signer.signApk(SourceFile:0)
at app.revanced.library.ApkUtils.sign(SourceFile:0)
at app.revanced.manager.flutter.MainActivity.runPatcher$lambda$35(Unknown Source:520)
at app.revanced.manager.flutter.MainActivity.$r8$lambda$t9VOe3aFJZkCMY59Ya4Pcinu-pA(SourceFile:0)
at app.revanced.manager.flutter.MainActivity$$ExternalSyntheticLambda6.run(SourceFile:0)
at java.lang.Thread.run(Thread.java:1012)
Caused by: com.android.apksig.zip.ZipFormatException: Data Descriptor presence mismatch between Local File Header and Central Directory for entry AndroidManifest.xml. LFH: true, CD: false
at com.android.apksig.internal.zip.LocalFileRecord.getRecord(SourceFile:0)
at com.android.apksig.internal.zip.LocalFileRecord.outputUncompressedData(SourceFile:0)
at com.android.apksig.internal.zip.LocalFileRecord.getUncompressedData(Unknown Source:27)
at com.android.apksig.ApkSigner.getAndroidManifestFromApk(Unknown Source:12)
at com.android.apksig.ApkSigner.getMinSdkVersionFromApk(Unknown Source:0)
... 8 more
You may try it yourself...
@SubZero5
Unrelated issue, I am trying to fix Exception at com.reandroid.arsc.chunk.xml.ResXmlElement.removeUnusedNamespaces(ResXmlElement.java:306)
Your case could be related to signatures block use flag -clean-meta
during merge
Your case could be related to signatures block use flag
-clean-meta
during merge
Hi ~
I already using -clean-meta
flag, but still giving me error message:
com.android.apksig.apk.MinSdkVersionException: Failed to determine APK's minimum supported Android platform version
at com.android.apksig.ApkSigner.getMinSdkVersionFromApk(ApkSigner.java:1006)
at com.android.apksig.ApkSigner.sign(ApkSigner.java:295)
at com.android.apksig.ApkSigner.sign(ApkSigner.java:231)
at app.revanced.library.ApkSigner$Signer.signApk(ApkSigner.kt:337)
at app.revanced.library.ApkUtils.signApk(ApkUtils.kt:169)
at app.revanced.cli.command.PatchCommand.run(PatchCommand.kt:321)
at picocli.CommandLine.executeUserObject(CommandLine.java:2026)
at picocli.CommandLine.access$1500(CommandLine.java:148)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
at picocli.CommandLine.execute(CommandLine.java:2170)
at app.revanced.cli.command.MainCommandKt.main(MainCommand.kt:12)
Caused by: com.android.apksig.zip.ZipFormatException: Data Descriptor presence mismatch between Local File Header and Central Directory for entry AndroidManifest.xml. LFH: true, CD: false
at com.android.apksig.internal.zip.LocalFileRecord.getRecord(LocalFileRecord.java:180)
at com.android.apksig.internal.zip.LocalFileRecord.outputUncompressedData(LocalFileRecord.java:427)
at com.android.apksig.internal.zip.LocalFileRecord.getUncompressedData(LocalFileRecord.java:451)
at com.android.apksig.ApkSigner.getAndroidManifestFromApk(ApkSigner.java:966)
at com.android.apksig.ApkSigner.getMinSdkVersionFromApk(ApkSigner.java:1004)
... 14 more
Is this issue from APKEditor or ReVanced CLI?
I don't know. Use apksigner.jar
from stock android sdk build-tools to sign your merged apk, this should tell you where the problem is
Caused by: com.android.apksig.zip.ZipFormatException: Data Descriptor presence mismatch between Local File Header and Central Directory for entry AndroidManifest.xml. LFH: true, CD: false
The problem is with ZIP data descriptors, it's not a problem in the signature or AndroidManifest itself, but happens for all the files that are modified during merging I think (If you remove signature and preserve AndroidManifest.xml, same Data Descriptor presence mismatch exception thrown for resources.arsc).
I thought this is a mistake in apksig, because the APK will work fine if you remove the exception, but it's not (well it might still be unnecessary validation, but as Maximoff (developer of Apktool M) noted, apksig does not throw this exception for merged APKs normally, only in ReVanced Manager/CLI, so he thinks it may be caused by something when patching).
I don't know what exactly causes it or why, but I don't think this is a problem specific to APKEditor, because APKs merged by Apktool M and AntiSplit G2 have the same problem when patching with ReVanced. In AntiSplit M I simply removed the code from REAndroid which writes data descriptor, it works fine for merging, but I don't know if it would break other functions.