I've tried to implement the suggested line that I got from here, but it didn't work and the app crashed.
This is the original code:
.method public final getHasDrawn()Ljava/lang/String;
.registers 2
iget-object v0, p0, Lcom/abcjean/skull/User;->hasdrawn:Ljava/lang/String;
return-object v0
.end method
And by adding the new line using sget-object, I wrote it this way:
.method public final getHasDrawn()Ljava/lang/String;
.registers 2
iget-object v0, p0, Lcom/abcjean/skull/User;->hasdrawn:Ljava/lang/String;
sget-object v0, Lcom/abcjean/skull/User;->TRUE:Ljava/lang/String;
return-object v0
.end method`
I wish I could make this method to return true, but the only problem is the app keeps crashing. So I assume that the code above is written incorrectly. Is it possible to do this?
The app keeps crashing because your new code is invalid, I have added some comments to the original code:
So there are 2 errors for your code:
getHasDrawn()is not returning ajava.lang.String, which the other code are most likely expecting it to be doing so.com/abcjean/skull/User;->TRUE:Ljava/lang/String;is not valid. It should bejava/lang/Boolean;->TRUE:Ljava/lang/String;as in the question you had linked to, if you intended to returnjava.lang.Boolean.TRUE. The line is referring to a object identifer namedTRUE, which is of typejava.lang.BooleanI would need more context on what you are trying to achieve to truly solve your problem.
Here is a rough sketch of what a solution might be, assuming your goal is to make
getHasDrawn()return a string primitive"yes":Most likely, you should be looking at other methods that returns a boolean that blocks your access to a certain view of the target app. Unless the app uses string instead of boolean to do so.
Read more on
smalisyntax on the official docs:Another suggestion unrelated to your question, is that from my experience you will have a better chance just hooking up a reverse proxy and read the API calls to achieve your reverse-engineering goals without editing the
smali/ decompiledjavacode.