Skip to content

Fix Modder test failures - #108

Open
pamod-madubashana wants to merge 13 commits into
KuhakuPixel:masterfrom
pamod-madubashana:master
Open

Fix Modder test failures#108
pamod-madubashana wants to merge 13 commits into
KuhakuPixel:masterfrom
pamod-madubashana:master

Conversation

@pamod-madubashana

Copy link
Copy Markdown

Fixes all 20 Modder test failures by resolving:

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

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

  3. Charset encoding: Files.readString() uses platform default charset and fails on binary XML manifests. Switched to explicit UTF-8 readAllBytes.

  4. Shutdown hook cleanup: Replaced FileUtils.deleteDirectory with native recursive delete to avoid the commons-io conflict during JVM shutdown.

…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
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.
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant