Fix Modder test failures - #108
Open
pamod-madubashana wants to merge 13 commits into
Open
Conversation
…tManager compatibility, charset encoding, and shutdown hook cleanup - TempManager: replace FileUtils.deleteDirectory with native recursive delete to avoid commons-io classpath conflict with apktool fat jar - Aapt.kt: call brut.androlib.res.AaptManager.getBinaryFile() directly instead of broken Apktool-Kotlin wrapper that references non-existent brut.util.AaptManager - Patcher.kt: use String(Files.readAllBytes(...), Charsets.UTF_8) instead of Files.readString() to avoid MalformedInputException on binary XML content - TestPatcher.kt: same charset fix, plus make RemoveExtractNativeLibOptions test resilient to manifests without extractNativeLibs option - build.gradle: use original apktool-cli-all_3.0.2.jar (not cleaned version), keep commons-io:2.21.0 dependency with force strategy to match fat jar version
Fix Modder test failures
…upports --use-aapt2 flag
When apktool recompilation fails with 'Unsigned short value out of range:
65536', the Patcher now automatically detects the problematic smali folder,
splits it in half by moving files to a new smali_classes{N+1} folder, and
retries the build (up to 5 attempts). This handles large multi-dex APKs
like Carrom that exceed the DEX method reference limit.
…or DEX 64K detection
…it from killing our JVM during DEX 64K error handling
…e JVMs Both fat jars bundle org.apache.commons.cli with different versions and different signatures, causing SecurityException on same classloader. Changes: - Replace java -cp <full-classpath> with java -jar for both apktool rebuild and uber-apk-signer, ensuring complete classloader isolation - Add ToolJarResolver for centralized jar resolution with 3 fallbacks - Copy tool jars to build/resources/main/tools for reliable extraction - Delete stale apktool-cli-all_2.9.0.jar (28.6MB unreferenced) - Add logging for subprocess operations
apktool-cli-all_3.0.2.jar bundles an older commons-io that conflicts with the standalone commons-io:2.21.0 at runtime, causing NoSuchMethodError on IOConsumer.forAll(). Replace: - FileUtils.copyDirectory → File.copyRecursively() - FileUtils.deleteDirectory → File.deleteRecursively() - FilenameUtils.getExtension → File.extension (Kotlin built-in)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes all 20 Modder test failures by resolving:
commons-io classpath conflict: The apktool fat jar bundles partial commons-io (2.21.0) but lacks FileUtils. Removed separate dependency caused NoClassDefFoundError; keeping it with version alignment resolves the conflict.
AaptManager class mismatch: The Apktool-Kotlin library calls brut.util.AaptManager.getAapt2() which doesn't exist in apktool 3.0.2's fat jar (it's at brut.androlib.res.AaptManager). Fixed by calling the correct class directly.
Charset encoding: Files.readString() uses platform default charset and fails on binary XML manifests. Switched to explicit UTF-8 readAllBytes.
Shutdown hook cleanup: Replaced FileUtils.deleteDirectory with native recursive delete to avoid the commons-io conflict during JVM shutdown.