Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MERGE APK Failed #116

Closed
c01ns opened this issue Aug 5, 2024 · 9 comments
Closed

MERGE APK Failed #116

c01ns opened this issue Aug 5, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@c01ns
Copy link

c01ns commented Aug 5, 2024

Describe the bug
MERGE APK Failed

To Reproduce
Steps to reproduce the behavior:

  1. Used version '1.3.9'
  2. 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)

Log/Stacktrace
image

Used apk file
com.GencSadiku.CarSimOpenWorld

Additional context
Add any other context about the problem here.

@c01ns
Copy link
Author

c01ns commented Aug 5, 2024

is my java version too lower,use jdk17 is working

@c01ns c01ns closed this as completed Aug 5, 2024
@REAndroid REAndroid added the bug Something isn't working label Aug 10, 2024
@REAndroid
Copy link
Owner

@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.

@REAndroid REAndroid reopened this Aug 10, 2024
@c01ns c01ns closed this as completed Aug 12, 2024
@c01ns c01ns reopened this Aug 12, 2024
@SubZero5
Copy link

@REAndroid
Copy link
Owner

@c01ns @SubZero5
Please confirm 796cc8d fixes this issue,

Jar is available at action run 10616226207

@SubZero5
Copy link

SubZero5 commented Aug 29, 2024

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...

@REAndroid
Copy link
Owner

REAndroid commented Aug 29, 2024

@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

@cyberboh
Copy link

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?

@REAndroid
Copy link
Owner

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

@AbdurazaaqMohammed
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants