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

Zipaligning the APK may have failed. Read the following output to determine if zipalign actually had an error: #648

Open
manojssc opened this issue Nov 22, 2023 · 1 comment

Comments

@manojssc
Copy link

┌──(objection)─(kali㉿kali)-[~/Desktop]
└─$ objection patchapk --source app-release.apk -a x86_64
Using latest Github gadget version: 16.1.7
Patcher will be using Gadget version: 16.1.7
Detected apktool version as: 2.9.0
Running apktool empty-framework-dir...
I: Removing 1.apk framework file...
Unpacking app-release.apk
An error may have occurred while extracting the APK.
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true

App does not have android.permission.INTERNET, attempting to patch the AndroidManifest.xml...
Injecting permission: android.permission.INTERNET
Writing new Android manifest...
Target class not specified, searching for launchable activity instead...
Reading smali from: /tmp/tmpvzojrn7j.apktemp/smali/asvid/github/io/fridaapp/MainActivity.smali
Injecting loadLibrary call at line: 62
Attempting to fix the constructors .locals count
Current locals value is 0, updating to 1:
Writing patched smali back to: /tmp/tmpvzojrn7j.apktemp/smali/asvid/github/io/fridaapp/MainActivity.smali
Creating library path: /tmp/tmpvzojrn7j.apktemp/lib/x86_64
Copying Frida gadget to libs path...
Rebuilding the APK with the frida-gadget loaded...
Rebuilding the APK may have failed. Read the following output to determine if apktool actually had an error:

Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true

Built new APK with injected loadLibrary and frida-gadget
Performing zipalign
Zipaligning the APK may have failed. Read the following output to determine if zipalign actually had an error:

/usr/bin/zipalign: symbol lookup error: /usr/bin/zipalign: undefined symbol: _ZN11zip_archive6WriterD2Ev

Zipalign completed
Signing new APK.
Signing the new APK may have failed.

Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Exception in thread "main" java.io.FileNotFoundException: /tmp/tmpvzojrn7j.apktemp.aligned.objection.apk (No such file or directory)
at java.base/java.io.RandomAccessFile.open0(Native Method)
at java.base/java.io.RandomAccessFile.open(RandomAccessFile.java:344)
at java.base/java.io.RandomAccessFile.(RandomAccessFile.java:259)
at java.base/java.io.RandomAccessFile.(RandomAccessFile.java:213)
at com.android.apksig.ApkSigner.sign(ApkSigner.java:190)
at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:356)
at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:85)

Signed the new APK
Copying final apk from /tmp/tmpvzojrn7j.apktemp.aligned.objection.apk to app-release.objection.apk in current directory...
Traceback (most recent call last):
File "/home/kali/.venvs/objection/bin/objection", line 8, in
sys.exit(cli())
^^^^^
File "/home/kali/.venvs/objection/lib/python3.11/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/kali/.venvs/objection/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/home/kali/.venvs/objection/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/kali/.venvs/objection/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/kali/.venvs/objection/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/kali/.venvs/objection/lib/python3.11/site-packages/objection/console/cli.py", line 373, in patchapk
patch_android_apk(**locals())
File "/home/kali/.venvs/objection/lib/python3.11/site-packages/objection/commands/mobile_packages.py", line 230, in patch_android_apk
shutil.copyfile(patcher.get_patched_apk_path(), os.path.join(os.path.abspath('.'), destination))
File "/usr/lib/python3.11/shutil.py", line 256, in copyfile
with open(src, 'rb') as fsrc:
^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpvzojrn7j.apktemp.aligned.objection.apk'
Cleaning up temp files...

I have got many warnings from unpacking to signing the apk, and finally it results in no such file or directory.... Please anyone help me with this, tried the available solutions but the error is not changing

@mateofumis
Copy link

I've had the same problem.

The solution that worked for me in Kali Linux:

Use Docker image "andrewmackrodt/objection"

docker run --rm -it -v "$PWD:/data" -w /data andrewmackrodt/objection \
  -- \
  patchapk -s MyApp.apk -a arm64-v8a

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

No branches or pull requests

2 participants