1

Decompiling and recompiling an apk causes it to crash. My goal is simply to insert a method into smali code that prints a stacktrace, but even decompiling and recompiling with no changes causes the modified apk to crash. Apktool says everything goes fine, but when the recompiled apk is installed it crashes instantly.

the decompiled and recompiled apk's log

log of the unmodified version installed from Play Store

It seems as if Apktool doesn't properly recompile.

4
  • 1
    I would first test if the app works at all if you only resign it (without de- and recompiling). If the app checks it's own signature it can intentionally force and app crash if it detects that the signature was changed. So the problem may be unrelated to apktool.
    – Robert
    Oct 29, 2022 at 11:52
  • Can confirm that simply resigning the apk causes the app to crash, so it seems that the app is checking the signature. How can I solve this?
    – Sid
    Oct 29, 2022 at 13:32
  • Search for the code that checks the signature. It may be implemented in Dex code or in native (.so files) code.
    – Robert
    Oct 29, 2022 at 16:59
  • So for me only resigning the apk and installing causes no problems,so where could be the issue if i decompile it and compile it back without any modifications? I resigned it using apk easy tool
    – Ehab Alaa
    Jun 18, 2023 at 23:14

2 Answers 2

1

You are likely working with a split-config application and you're only re-signing and installing the base APK. You need to also install additional APKs from the bundle (also known as XAPK). Details here: https://developer.android.com/guide/app-bundle/#dynamic_delivery

2
  • Your answer is a valuable information for apktool users, however as written in the comments even resigning the APK without using apktool triggers the problem. Therefore apktool is not the problem here.
    – Robert
    Dec 18, 2022 at 8:19
  • This has become my personal project for a while now, and I can confirm that this answer is incorrect. This app seems to be a rebranded version of another app, which definitely checks its own signature: github.com/nalajcie/tuya-sign-hacking. In addition, I've been installing both apks even before this question was asked, because if one is left out, adb install gets angry.
    – Sid
    Dec 18, 2022 at 23:54
1

As commented by Robert, the answer for me in this case was that the signature was being checked by the app itself, and the app was causing the crash as a result of detecting modification to the app. If you want to solve this problem, get ready for a long project. If the developers of the app care even a little about the security of their app, they can make it incredibly difficult to modify the app. I would recommend looking up reverse engineering tools such as Ghidra and Frida that might be able to help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.