I had below smali code that worked well with no error.I have add an statement after the move-result to log v18 at logcat, but now I have an error
    invoke-static {v9}, Lcom/mycompany/myapp/MyClass1;->getMystring((Ljava/lang/Object;)Ljava/lang/String;
    move-result-object v18
    #I added below line 
    invoke-static {v18}, Lcom/mycompany/myapp/MyClass2;->logMessage(Ljava/lang/String;)V
but I have error now:
    Invalid register: v18. Must be between v0 and v15, inclusive
What should I use instead of v18 to remove the error in the last line
 
                        
invoke-staticis one of the instructions that can address only the first 16 registers (v0tov15as said in the error message). There are a few options, all of them involve finding a register that you can use for yourself.Replace
v18inmove-result-objectwith another register. You might need to update its uses in other places accordingly.Copy value from
v18into another register usingmove-object vX, v18wherevXis the new register and useinvoke-staticwithvX.If you can't find a register that would be safe to override, you can temporary copy it to a register with a higher index using
move-object/16 vYY, vXand then restore it withmove-object/from16 vX, vYY. You'll need to increase the number of registers the function uses.Note that registers aren't shared between methods, so you need to care only about preserving the behavior of the current method.