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

syntax error in encoding #12

Closed
54696d21 opened this issue Jan 23, 2020 · 8 comments
Closed

syntax error in encoding #12

54696d21 opened this issue Jan 23, 2020 · 8 comments
Labels
apktool Issues caused by or related to Apktool

Comments

@54696d21
Copy link

I tried using your program under a x64 Arch installation and on a raspberry pi (both times using openjdk 11). The error report below is from the raspberry pi. The apk was the latest tiktok apk. I'd be very grateful if you could help me solve this error.

➜  ~ npx apk-mitm android.apk
npx: installed 139 in 20.205s

  ╭ apk-mitm v0.6.2
  ├ apktool v2.4.1
  ╰ uber-apk-signer v1.1.0

  Using temporary directory:
  /tmp/7aef2cab1cc5ca0794c0f29396515b6c

  ✔ Decoding APK file
  ✔ Modifying app manifest
  ✔ Modifying network security config
  ✔ Disabling certificate pinning
  ❯ Encoding patched APK file
    ↓ Encoding using AAPT2 [skipped]
      → Failed, falling back to AAPT...
    ✖ Encoding using AAPT [fallback]
      → Command failed with exit code 1: java -jar /home/pi/.npm/_npx/18012/lib/node_modules/a
…
    Signing patched APK file

   Failed!  An error occurred:

 Error: Command failed with exit code 1: java -jar /home/pi/.npm/_npx/18012/lib/node_modules/apk-mitm/jar/apktool.jar build /tmp/7aef2cab1cc5ca0794c0f29396515b6c/decode --output /tmp/7aef2cab1cc5ca0794c0f29396515b6c/tmp.apk

 brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 2): [/tmp/brut_util_Jar_11860541976089287700.tmp, p, --forced-package-id, 127, --min-sdk-version, 16, --target-sdk-version, 28, --version-code, 2021407050, --version-name, 14.7.5, --no-version-vectors, -F, /tmp/APKTOOL15023095336353795217.tmp, -e, /tmp/APKTOOL8221647891385303484.tmp, -0, arsc, -I, /home/pi/.local/share/apktool/framework/1.apk, -S, /tmp/7aef2cab1cc5ca0794c0f29396515b6c/decode/res, -M, /tmp/7aef2cab1cc5ca0794c0f29396515b6c/decode/AndroidManifest.xml]     
W: /tmp/brut_util_Jar_11860541976089287700.tmp: 2: /tmp/brut_util_Jar_11860541976089287700.tmp: Syntax error: "(" unexpected

@shroudedcode
Copy link
Owner

This error seems to be caused by Apktool which apk-mitm is based on. To narrow down the issue you could try manually decoding and re-encoding the APK without making any changes. For that, you can use the jar/apktool.jar file bundled with apk-mitm:

# Decode to "decoded" directory
java -jar ./apktool.jar decode android.apk --output decoded

# Re-encode to "android-reencoded.apk"
java -jar ./apktool.jar build decoded --output android-reencoded.apk

If that fails the issue is probably not something I can fix but rather an issue with Apktool or a mistake/oddity in TikTok's source code.

@54696d21
Copy link
Author

Thank you very much, there's also an error when reencoding the apk file with just using apktool

@shroudedcode
Copy link
Owner

I found multiple issues related to the Syntax error: "(" unexpected error you're getting on the Apktool repository. Two of them (#974 and #2092) are related to the ARM CPU architecture used by Raspberry Pi's. AAPT which is used by Apktool doesn't seem to work on ARM, so you can't use Apktool or apk-mitm on your Raspberry Pi.

This makes me wonder: Are you getting the same error or a different one on your Arch installation?

@54696d21
Copy link
Author

I'll try it running it on arch x64 again. It's weird that apktool is in the repository for raspbian...

@shroudedcode
Copy link
Owner

It's weird that apktool is in the repository for raspbian...

That is weird. Maybe that package is built using a patched version of AAPT or it used to work and just doesn't anymore.

@54696d21
Copy link
Author

54696d21 commented Jan 24, 2020

the raspbian version an older one (i think it was before 2.4) but decompiling works fine

and yeah doesn't work on x64 either

maybe its worth trying build for another sdk version?

 java -jar apktool_2.4.1.jar  build decoded --output reencoded.apk
I: Using Apktool 2.4.1
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes4 folder into classes4.dex...
I: Checking whether sources has changed...
I: Smaling smali_assets folder into assets.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes6 folder into classes6.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes2 folder into classes2.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes3 folder into classes3.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes7 folder into classes7.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes5 folder into classes5.dex...
I: Checking whether resources has changed...
I: Building resources...
W: /home/marc/androidDecomp/decoded/res/values-v21/styles.xml:269: error: Resource entry j6 already has bag item android:windowContentTransitions.
W: /home/marc/androidDecomp/decoded/res/values-v21/styles.xml:268: Originally defined here.
W: 
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_10373368146805472863.tmp, p, --forced-package-id, 127, --min-sdk-version, 16, --target-sdk-version, 28, --version-code, 2021407050, --version-name, 14.7.5, --no-version-vectors, -F, /tmp/APKTOOL14351557212148640520.tmp, -e, /tmp/APKTOOL6742344768126141054.tmp, -0, arsc, -I, /home/marc/.local/share/apktool/framework/1.apk, -S, /home/marc/androidDecomp/decoded/res, -M, /home/marc/androidDecomp/decoded/AndroidManifest.xml]

@54696d21
Copy link
Author

Ok the sdk version thing i suggested makes no sense. I guess the issue can be closed. Thank you very much :)

@shroudedcode
Copy link
Owner

No problem! Sorry I couldn't be more helpful here, but unfortunately there's not much I can do if Apktool can't decode or encode a certain APK. There's some issues about this Resource entry already has bag item error on the Apktool repository, so I'd recommend taking a look at those and up-voting the ones matching your problem. Maybe someone has even found a way to solve this problem.

@shroudedcode shroudedcode added the apktool Issues caused by or related to Apktool label Jan 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apktool Issues caused by or related to Apktool
Projects
None yet
Development

No branches or pull requests

2 participants