Skip to content

Conversation

aancw
Copy link

@aancw aancw commented Sep 17, 2025

Description

This PR updates Objection to fully support the latest apktool version by:

  • Switching from aapt to aapt2, which is now the default in apktool.
  • Removing the deprecated --use-aapt2 flag.
  • Fixing command construction to avoid passing empty string arguments to apktool.
  • Updating the version check command to use v instead of the old -version flag.

These updates ensure Objection remains compatible and stable with the newest apktool releases.

Here is the log:

❯ objection patchapk -s fluttersamples.apk -a arm64
Using latest Github gadget version: 17.3.0
Patcher will be using Gadget version: 17.3.0
Detected apktool version as: 2.12.0
Running apktool empty-framework-dir...
I: Removing framework file: 1.apk
Unpacking fluttersamples.apk
App already has android.permission.INTERNET
Target class not specified, searching for launchable activity instead...
Reading smali from: /var/folders/_8/v5b47jgd4p529gtngdp1778c0000gn/T/tmpi05vnu2h.apktemp/smali/cm/aptoide/pt/view/MainActivity.smali
Injecting loadLibrary call at line: 86
Attempting to fix the constructors .locals count
Current locals value is 0, updating to 1:
Writing patched smali back to: /var/folders/_8/v5b47jgd4p529gtngdp1778c0000gn/T/tmpi05vnu2h.apktemp/smali/cm/aptoide/pt/view/MainActivity.smali
Creating library path: /var/folders/_8/v5b47jgd4p529gtngdp1778c0000gn/T/tmpi05vnu2h.apktemp/lib/arm64
Copying Frida gadget to libs path...
Rebuilding the APK with the frida-gadget loaded...
Built new APK with injected loadLibrary and frida-gadget
Performing zipalign
Zipalign completed
Signing new APK.
Signing the new APK may have failed.

WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::loadLibrary has been called by org.conscrypt.NativeLibraryUtil in an unnamed module (file:/Users/Library/Android/sdk/build-tools/36.0.0/lib/apksigner.jar)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled

Unexpected parameter(s) after input APK (--enable-native-access=ALL-UNNAMED)

Signed the new APK
Copying final apk from /var/folders/_8/v5b47jgd4p529gtngdp1778c0000gn/T/tmpi05vnu2h.apktemp.aligned.objection.apk to fluttersamples.objection.apk in current directory...
Cleaning up temp files...

❯ ls | grep flutter
fluttersamples.apk
fluttersamples.objection.apk

@aancw
Copy link
Author

aancw commented Sep 17, 2025

I initially thought this patch might duplicate the changes in #753, but after reviewing it more closely, this PR includes additional improvements not covered there:

  • Switch from aapt to aapt2, matching apktool's current default.
  • Remove the now-unnecessary --use-aapt2 flag.
  • Clean up apktool command construction to avoid passing empty string arguments (using filter(None, [...])).

These changes improve compatibility and reduce possible issues when using the latest apktool.

Happy to adjust or collaborate if needed.

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