[Sony Ericsson Xperia Mini, Mini Pro, Xperia Pro, A] havocgb:
Thanks guys! After all the hours sitting trying to understand smali it feels good to see atleast some people liked it! :laugh:

Anyways so I was a total noob at smali and java 2 weeks ago. I knew c/c++ and that's it. So if u want to get into smali coding let me tell you what I did.

Stuff you will need:

-APK One-Click : One hell of a tool. Makes life so easy. Basically its going to extract the apk,get the .dex files and try to reconstruct the java source code, all in one click! That said its NOT going to give you the actual java source code. Its just a tool to understand how the source code could be in a well written format (similar to a java program). It saves you the pain of sitting and looking at .smali files and trying to understand them :P From my experience it screws up almost all the if, while loops. So you still need to understand smali.

-APK Multi-tool: There are many tools out there that lets you pull out smali files out of apks and later recompile them back to apks after you edit the .smali files. I used APK Multi-tool for this purpose and I would say it works really well with system apps as the tool handles system apps seperately and has a decent UI

(Don't forget to say thanks to the guys who made these tools if these come in handy for you!)

So first thing to do would be to get these two tools working. After that you can start decompiling apks and see how their smali files look like (using APK Multi-tool) and how their correspoding java source code could have been (using APK One-Click)

Now is the hard part - Understanding .smali. Its not that easy but its nothing impossible. If you spend time you will be able to figure it out :)

The resources to understand are below (some of these I got from an earlier post in this thread by the great serajr :highfive:)

-http://www.milk.com/kodebase/dalvik-docs-mirror/docs/dalvik-bytecode.html

-http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html

These two has descriptions of what most of the .smali commands mean. So when you are looking at smali code and don't understand what for example cmpl-float means you can look for it in those two pages and understand.

-http://babbage.cs.qc.cuny.edu/IEEE-754/index.xhtml

This is a handy tool to convert decimal numbers (what humans use) to hexadecimal numbers under the IEEE-754 standard (which smali uses)

-One of the best ways (but also bit hard to start off) would be to use Android ADT to write your own java code and build a test apk and then use the above tools to decompile and obtain the .smali files so that you can see how your java statements look in smali.

Say for example, a while statement. smali being an assembly language (as far as I've understood) doesn't have while loops. So you can write make a silly apk, say the screen shows hello world while your finger is touching the screen and then decompile it and look at the .smali code to understand how to make while loops in smali. Then you can take the systemUI.apk and decompile to obtain .smali files, edit it and put while loops in it.

And yeah if you guys haven't done yet, then use notepad++ to edit the text in the .smali files. Its better than notepad/wordpad for this purpose. You can get proper syntax highlighted in notepad++ by importing the .xml file for smali. Google for "notepad++ smali user defined language" and find the .xml. Import it in notepad++ as a new user defined language by going to Language>Define you language.. in notepad++. I can't share the .xml file here due to some reasons :P

Maybe all this might look like a bit too much of work. Well I would say yes this is a bit of work. But its fun if you like coding and debugging :D And I bet you would get a faster start than me with smali cz of this post. I was so big a noob that I was sitting and downloading the whole android source repo first thinking I can edit android source code and make a systemUI.apk :P

---------- Post added at 01:28 AM ---------- Previous post was at 01:24 AM ----------

Thanks for the feedback bro! :)