javaandroiddebuggingdalviksmali

how to locate the register problem in Android after modifying some smali code of an APK?


I would like to add something to an app, so I added some lines to a smali file (decompiled the apk using apktools) and then repackaged and ran it on a real device. It shows

So what does the [0x161] refer to? Is it a line number? 0x161 = 353 in decimal. So I checked the smali code, but the function a.b.a.a.a.i.m has less than 353 lines in smali, so there is no line 353 and I can not locate the error.

Neither does this function have enough lines in java (I used jadx to decompiled the generated apk).

So in which type of file can I locate the problem in file's line 353? Should I transformed the apk into some other format to find a line 353 to troubleshoot the error? Thanks in advance.


Solution

  • 0x161 should be the relative offset/address in bytes from the start of the method.

    In Jadx open the Smali tab for the class you are interested in and select Show Dalvik Bytecode from context menu of the smali code panel to see the offsets. The offset you are looking for should be shown in the second gray colored column (the one with the red border in the sample screenshot).

    Example Jadx smali code view

    And the error should be caused by placing a wrong object reference in v0.