1

unable repack smali files error code:apktool invalid literal value low 16 bits must be zeroes out.

which register value should i use in place of ""const/high16 v4""" with replaced value 0x7f04006a

.line 11
move-object v3, v0

move-object v4, v1

invoke-super {v3, v4}, Landroid/app/Activity;->onCreate(Landroid/os/Bundle;)V

.line 12
move-object v3, v0

const/high16 v4, 0x7f030000

invoke-virtual {v3, v4}, Lcom/mycompany/myapp/MainActivity;->setContentView(I)V

return-void

.end method

My public id is <public type="layout" name="main" id="0x7f04006a" />

1 Answers1

0

The const/high16 instruction accepts a 16 bit literal, shifts it left by 16 bits and loads it into the specified register.

The smali syntax for this instruction uses the post-shifted literal value. So in your example const/high16 v4, 0x7f030000, in the raw bytecode, the actual literal argument to the instruction would be 0x7f03. But in the smali syntax, it's specified as the post-shifted form: 0x7f030000. Since this is the post-shifted form, the last 4 hex digits must always be 0.

If you want to load a literal value that doesn't meet these requirements, you must use a different instruction, like the const instruction.

const v4, 0x7f04006a
JesusFreke
  • 19,784
  • 5
  • 65
  • 68
  • after setting conts v4, x70f04006a apk gets compiled but main activity does not start here is log. ->>12-28 11:20:57.455 E/AndroidRuntime( 9521): java.lang.VerifyError: Verifier rejected class com.mycompany.myapp2.MainActivity: void com.mycompany.myapp2.MainActivity.onCreate(android.os.Bundle): [0xFFFFFFFF] register index out of range (7 >= 7) (declaration of 'com.mycompany.myapp2.MainActivity' – user9330612 Dec 30 '18 at 13:16
  • what other changes did you make? – JesusFreke Dec 30 '18 at 20:20
  • no other changes ,i have source code of my test app ,i want to put my test app smali files into another apk which i do not have source code. The problem is in setting layout to activity in my test app if i remove layout in my test activity and than merge smali files, than apk gets compiled and run properly. – user9330612 Dec 31 '18 at 02:03
  • Well, from the error message, you're doing something that uses register v7 in a method with only 7 registers - which means only v0-v6 is available. – JesusFreke Dec 31 '18 at 06:11