[Galaxy S II Q&A, Help & Troubleshooting] davidwilson83:
G'Day XDA,

Just wondering if someone out there could please give me some advice or point me in the right direction.

I am editing an apk called SamsungWidget_Program Monitor which looks like this...

Now the thing is I am trying to edit the smali code to change that orange 0 and also the white "Active Applications' text. I have found the text that I need to edit which is fine. But every time I edit it I get errors when recompiling.

I use a stock odexed rom, so I had to deodex the apk using dsixda's Android Kitchen. That worked fine and I had no problems in doing that, as I have done before with other apks. After doedexing I decompiled the apk using Wanam's APKTool which again worked flawlessly. Then I edit 4 separate bits of code in 1 smali file which is just changing a colour from either orange or white to ICS blue, save the smali file, recompile and I keep getting errors. If I edit just the first bit of code, everything recompiles perfectly. But however, if I edit any of the other 3 bits of code, I get problems.

Here are the codes (in bold) from the ProgramMonitorWidgetProvider.smali file which I want to edit...

.method public constructor <init>()V
.registers 4

.prologue
const/16 v2, [B]-0x5900[/B]

const/high16 v1, [B]-0x1[/B]

.line 21
invoke-direct {p0}, Landroid/appwidget/AppWidgetProvider;-><init>()V

.line 42
iput v2, p0, Lcom/sec/android/widgetapp/programmonitorwidget/ProgramMonitorWidgetProvider;->program_monitor_number_text_color:I

.line 43
iput v1, p0, Lcom/sec/android/widgetapp/programmonitorwidget/ProgramMonitorWidgetProvider;->program_monitor_number_text_color_noti3:I

.line 44
const/4 v0, [B]-0x1[/B]

iput v0, p0, Lcom/sec/android/widgetapp/programmonitorwidget/ProgramMonitorWidgetProvider;->program_monitor_slide_text_color_normal:I

.line 45
iput v2, p0, Lcom/sec/android/widgetapp/programmonitorwidget/ProgramMonitorWidgetProvider;->program_monitor_slide_text_color_noti_1:I

.line 46
const v0, [B]-0xcc4a1b[/B]

Now I have successfully edited the last one to change the colour from a green colour to ICS Blue, but every time I change any of the other 3 pieces of code (the first one is the orange colour of the 0, the other 2 are the white 'Active Applications' text I'm pretty sure) I get the following recompile error using APKTool.

--------------------------------------------------------------------------
|Tue 23/10/2012 -- 22:30:22.95|
--------------------------------------------------------------------------
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) Client VM (build 23.5-b02, mixed mode, sharing)
I: Checking whether sources has changed...
I: Smaling...
Exception in thread "main" brut.androlib.AndrolibException: Could not smali file: java.io.FileInputStream@8fc809
at brut.androlib.src.DexFileBuilder.addSmaliFile(DexFileBuilder.java:45)
at brut.androlib.src.DexFileBuilder.addSmaliFile(DexFileBuilder.java:33)
at brut.androlib.src.SmaliBuilder.buildFile(SmaliBuilder.java:64)
at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:48)
at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:35)
at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:243)
at brut.androlib.Androlib.buildSources(Androlib.java:200)
at brut.androlib.Androlib.build(Androlib.java:191)
at brut.androlib.Androlib.build(Androlib.java:174)
at brut.apktool.Main.cmdBuild(Main.java:188)
at brut.apktool.Main.main(Main.java:70)

I have also tried to just use smali to recompile the apk, using a Command Window but I get different errors every time. If I edit the first bit of code (-0x5900) I get this error:

C:\David\Smali>java -Xmx512M -jar smali.jar deodexed_AppMan -o classes.dex
deodexed_AppMan\com\sec\android\widgetapp\programmonitorwidget\ProgramMonitorWid
getProvider.smali[0,0] -13388315 cannot fit into a short

Then if I put the first bit of code back to it's original -0x5900 and change the next bit of code (-0x1) to the ICS Blue colour (-0xcc4a1b) I get this error.

C:\David\Smali>java -Xmx512M -jar smali.jar deodexed_AppMan -o classes.dex
deodexed_AppMan\com\sec\android\widgetapp\programmonitorwidget\ProgramMonitorWid
getProvider.smali[0,0] -13388315 cannot fit into a short
deodexed_AppMan\com\sec\android\widgetapp\programmonitorwidget\ProgramMonitorWid
getProvider.smali[83,4] mismatched tree node: I_STATEMENT_FORMAT35c_METHOD expec
ting I_CATCHES
deodexed_AppMan\com\sec\android\widgetapp\programmonitorwidget\ProgramMonitorWid
getProvider.smali[86,4] mismatched tree node: I_STATEMENT_FORMAT22c_FIELD expect
ing <UP>

Now if I return that back to the original -0x1 and change the following bit of code (-0x1) to the ICS Blue colour (-0xcc4a1b) then I get this slightly different error.

C:\David\Smali>java -Xmx512M -jar smali.jar deodexed_AppMan -o classes.dex
deodexed_AppMan\com\sec\android\widgetapp\programmonitorwidget\ProgramMonitorWid
getProvider.smali[0,0] -13388315 cannot fit into a short
deodexed_AppMan\com\sec\android\widgetapp\programmonitorwidget\ProgramMonitorWid
getProvider.smali[94,4] mismatched tree node: I_STATEMENT_FORMAT22c_FIELD expect
ing I_CATCHES

Then if I change the first three bits of code back to original (as they are in the first bit of code I posted above) and only change the last one to -0xcc4a1b (again as it is in the first bit of code I posted above) then I get no errors.

I am not very skilled in Smali editing, it sees like another language to me, so I am wondering if someone could point me in the right direction to be able to edit all of those bits of code, and recompile without any errors.

Any help would be greatly appreciated.

Thanks XDA,

Dave