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

Build Failure with Apktool 2.9.3 on Linux due to Syntax Error in Temporary File #3498

Closed
Arab-developers opened this issue Jan 26, 2024 · 10 comments

Comments

@Arab-developers
Copy link

Information

  1. Apktool Version (apktool -version) - 2.9.3
  2. Operating System (Mac, Linux, Windows) - Linux (Kali)
  3. APK From? (Playstore, ROM, Other) - Playstore (Phone Directory & Caller ID)
  4. Java Version (java --version) - openjdk 17.0.10 2024-01-16 OpenJDK Runtime Environment (build 17.0.10+7-Debian-1) OpenJDK 64-Bit Server VM (build 17.0.10+7-Debian-1, mixed mode, sharing)

Stacktrace/Logcat

brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec (exit code = 2): [/tmp/brut_util_Jar_110116639072366788558884897057900241197.tmp, compile, --dir, /home/kali/Development/Apps/com.test/base/res, --legacy, -o, /home/kali/Development/Apps/com.test/base/build/resources.zip]
W: /tmp/brut_util_Jar_110116639072366788558884897057900241197.tmp: 4: Syntax error: Unterminated quoted string

Steps to Reproduce

  1. Run apktool d base.apk to decompile an APK.
  2. Make no changes to the decompiled files.
  3. Attempt to rebuild the APK with apktool b base.
  4. Observe the syntax error and build failure.

Frameworks

N/A - This issue occurred with a standard APK not specific to any OEM.

APK

The APK in question is available on the Playstore: Phone Directory & Caller ID.

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? - Yes, the error occurs even without making any changes to the decompiled APK.
  2. If you are trying to install a modified apk, did you resign it? - Not applicable, as the issue occurs during the build process before signing.
  3. Are you using the latest apktool version? - Yes, using Apktool 2.9.3.
@iBotPeaches
Copy link
Owner

May you pull the aapt(s) prebuilts from here and execute them in isolation to test? https://github.com/iBotPeaches/Apktool/tree/master/brut.apktool/apktool-lib/src/main/resources/prebuilt

My guess is one of 2 things is happening

  • Our copy of those binaries out of Apktool into /tmp for execution is not allowed for x reason
  • The architecture in play is invalid

They are static binaries so they should not depend on any shared objects.

@SebastiaanTheCoder
Copy link

Hey, was any solution found because I just ran into the exact same issue?

@iBotPeaches
Copy link
Owner

Hey, was any solution found because I just ran into the exact same issue?

Are you positive its the same issue? If so, may you follow my unanswered question above?

@MohamedAl-Kainai
Copy link

May you pull the aapt(s) prebuilts from here and execute them in isolation to test? https://github.com/iBotPeaches/Apktool/tree/master/brut.apktool/apktool-lib/src/main/resources/prebuilt

My guess is one of 2 things is happening

  • Our copy of those binaries out of Apktool into /tmp for execution is not allowed for x reason
  • The architecture in play is invalid

They are static binaries so they should not depend on any shared objects.

Thank you for your suggestion. I followed your instructions to pull and execute the aapt prebuilts in isolation. Here are the results I obtained:

When attempting to execute each of the binaries (aapt, aapt2, aapt_64, and aapt2_64), I encountered an "exec format error" for each one. This suggests that the binaries are incompatible with my system's architecture.

I'm currently running Kali Linux Rolling 2023.4 on an Apple M2 MacBook, installed via a virtual machine (VMware) that supports Apple Silicon. The system is using an aarch64 architecture as indicated by the uname -a command output. However, upon inspecting the aapt binary with the file command, it's shown to be an ELF 32-bit LSB executable intended for Intel architectures, which confirms the incompatibility.

Given this information, it appears the issue lies with the architecture mismatch rather than permissions or the copy process of the binaries into /tmp for execution. The binaries are built for a different architecture than what's supported on my current setup, which is based on ARM architecture (Apple Silicon) within the VM environment.

Is there a version of these prebuilts available for ARM architectures, or would you recommend an alternative approach to running these tools on an ARM-based system?

Looking forward to your guidance.

@iBotPeaches
Copy link
Owner

Odd @MohamedAl-Kainai - I run apktool on my M1 - did the arch change between M2? I guess I'm a bit lost on the intended arch. If you are running Kali on a Apple M2, but inside a VM that supports Apple Silicon I guess I don't know what it should be. We have code to read Java vars to determine which arch/os to use.

Like maybe this mac binaries are the intended one? https://github.com/iBotPeaches/Apktool/tree/master/brut.apktool/apktool-lib/src/main/resources/prebuilt/macosx

@SebastiaanTheCoder
Copy link

A fix that worked for me is downgrading to 2.8.1 (not sure if this step is needed) and afterwards running the following command:
sudo apt install binfmt-support qemu-user-static
as found in #2407.

@iBotPeaches
Copy link
Owner

Thanks - good to know. So we either don't support the arch intended with aapt or improperly detecting the right arch to use.

@Arab-developers
Copy link
Author

A fix that worked for me is downgrading to 2.8.1 (not sure if this step is needed) and afterwards running the following command: sudo apt install binfmt-support qemu-user-static as found in #2407.

Thanks for sharing your solution! I tried running the command sudo apt install binfmt-support qemu-user-static without downgrading to 2.8.1, and it worked perfectly for me as well.

@MohamedAl-Kainai
Copy link

A fix that worked for me is downgrading to 2.8.1 (not sure if this step is needed) and afterwards running the following command: sudo apt install binfmt-support qemu-user-static as found in #2407.

This solution worked for me too, thanks!

@iBotPeaches
Copy link
Owner

May some of you with this issue give me an output of: java -XshowSettings:properties -version ?

I'm curious of a few of those to see if our OS Detection is invalid and feeding wrong arch binaries to you forcing the usage of qemu emulation.

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

4 participants