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

Error while encoding APK file with apk-mitm and Apktool #158

Open
Skuxblan opened this issue Apr 5, 2024 · 3 comments
Open

Error while encoding APK file with apk-mitm and Apktool #158

Skuxblan opened this issue Apr 5, 2024 · 3 comments

Comments

@Skuxblan
Copy link

Skuxblan commented Apr 5, 2024

Hello,
I ran into a problem when trying to use apk-mitm to decode and modify the APK file. There appears to be a bug with Apktool and AAPT during the encoding process. On default version of Apktool it stops on error while Decoding APK file

Here are the details:

apk-mitm version: 1.2.1
Apktool version: 2.9.3
APK file: com.facebook.orca_452.0.0.50.109-320409634_minAPI21(armeabi-v7a)(360,400,420,480dpi)_apkmirror.com.apk same error with different versions and different tested apk e.g. youtube
Operating system: Windows 11
Path to apktool.jar: C:\Windows\apktool.jar it's 2.9.3 but I have tried also with few oldest

During the encoding process, I receive many errors regarding invalid XML file paths in the res\color.2\ directory. Here is my console:

E:\android-unpinner>apk-mitm --apktool C:\Windows\apktool.jar "Messenger_452.0.0.50.109_apkcombo.com.apk"

  ╭ apk-mitm v1.2.1
  ├ apktool custom version
  ╰ uber-apk-signer v1.2.1

  Using temporary directory:
  C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2

  √ Checking prerequisities
  √ Decoding APK file
  √ Applying patches
  > Encoding patched APK file
    ↓ Encoding using AAPT2 [skipped]
      → Failed, falling back to AAPT...
    × Encoding using AAPT [fallback]
      → I: Building resources...
    Signing patched APK file

   Failed!  An error occurred:

I: Using Apktool 2.9.3
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether resources has changed...
I: Building resources...
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f170009.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f17000a.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f17000c.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f17000d.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f17000e.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f17000f.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f170010.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f170011.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f170012.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f170015.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f170016.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f170088.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f170089.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f1700ce.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f1700da.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f1700e2.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f1700e9.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f1700f7.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f170102.xml'.
W: error: invalid file path 'C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res\color.2\APKTOOL_DUMMYVAL_0x7f170103.xml'.
brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\Mateusz\AppData\Local\Temp\brut_util_Jar_17906002965217958657890834285878101796.tmp, compile, --dir, C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\res, --legacy, -o, C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\decode\build\resources.zip]

  The full logs of all commands are available here:
  C:\Users\Mateusz\AppData\Local\Temp\apk-mitm-181e80259811ac06885253714312dfb2\logs

I can also provide full logs if required. Could anyone help me understand what might be causing these errors and how to fix them?

Thank you for your help.

@Wjxfi
Copy link

Wjxfi commented Apr 30, 2024


apktool d -f -r apkfilename.apk
here -f is to replace previous decompiled apk's code and -r is to ignore the decompiling of resources.

this would prevent the resources from being decompiled and will simply copy the same resources when you recompile the apk.

However, it is not possible to set these apktool settings in mitm-app? I couldn't find it. Please help me

apktool -r d *.apk

just add -r .

-r, --no-res
This will prevent the decompile of resources. This keeps the resources.arsc intact without any decode. If only editing Java (smali) then this is the recommended action for faster decompile & rebuild

@Wjxfi
Copy link

Wjxfi commented May 1, 2024

Solution to the problem:

during --wait function you should copy the files to another location, add resources.arsc to the decoded folder and enter the path to the decoded folder in place of the former path to the application.

However, I got another problem: signing the app doesn't work. Lol. Stupidity

@wezabronsz
Copy link

wezabronsz commented May 2, 2024

Solution to the problem:

during --wait function you should copy the files to another location, add resources.arsc to the decoded folder and enter the path to the decoded folder in place of the former path to the application.

However, I got another problem: signing the app doesn't work. Lol. Stupidity

It's all about Apktool compatibility. I think only apktool dev can bring any changes to make it works. Check that: iBotPeaches/Apktool#3436

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

3 participants