Skip to content

bug: Dexless APKs cause a EmptyMultiDexContainerException #359

@Delta-official

Description

@Delta-official

Bug description

Currently, trying to patch an APK with no .dex files result in a EmptyMultiDexContainerException due to BytecodeContext always being loaded, regardless of whether the APK contains .dex files. For example, this can be encountered when patching the part of a split APK that contains native libraries.

Error logs

INFO: Loading patches
lanchon.multidexlib2.EmptyMultiDexContainerException: split_config.arm64_v8a.apk
        at lanchon.multidexlib2.MultiDexIO.readMultiDexContainer(MultiDexIO.java:41)
        at lanchon.multidexlib2.MultiDexIO.readDexFile(MultiDexIO.java:33)
        at app.revanced.patcher.patch.BytecodePatchContext.<init>(BytecodePatchContext.kt:48)
        at app.revanced.patcher.PatcherContext.<init>(PatcherContext.kt:40)
        at app.revanced.patcher.Patcher.<init>(Patcher.kt:19)
        at app.revanced.cli.command.PatchCommand.run(PatchCommand.kt:288)
        at picocli.CommandLine.executeUserObject(CommandLine.java:2030)
        at picocli.CommandLine.access$1500(CommandLine.java:148)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2465)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2457)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2419)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
        at picocli.CommandLine.execute(CommandLine.java:2174)
        at app.revanced.cli.command.MainCommandKt.main(MainCommand.kt:12)

Solution

One solution would be to wait for #73. However, I'd like to make a PR that would catch EmptyMultiDexContainerException in PatcherContext and set a field that would disable bytecode patching behaviour. This could mitigate the issue and allow resources patches to run normally without being blocked.

Additional context

No response

Acknowledgements

  • I have checked all open and closed bug reports and this is not a duplicate.
  • I have chosen an appropriate title.
  • All requested information has been provided properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug reportSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions