I have a working android application. of which i dont have a source code. I would like to debug a functionality of this application. I could successfully reverse engineer this application apk file using apktool - https://code.google.com/p/android-apktool/ This tool generates class files in smali format.
My requirement is :
- To be able to debug a method by adding debug logs.
- To be able to debug method calls by printing a stack trace.
To achieve this I need to inject/insert smali equivalent of a debug log or stack trace. I tried adding some smali instruction at the start of one of the method but it crashed with ClassVerifyError.
Example smali code -
.method public declared-synchronized b()V
.locals 2
.prologue
.line 87
monitor-enter p0
:try_start_0
iget-object v0, p0, Lcom/example/viewerlib/t/d;->a:Ljava/lang/Thread;
invoke-virtual {v0}, Ljava/lang/Thread;->isAlive()Z
:
:
Could someone help me out in adding smali debug logs. Thnx in advance.