
Dalvik Virtual Machine does not use java bytecode. Instead, it uses it’s own file format called dex (Dalvik Executable Format). It holds definition of multiple classes and relative data.
Smali /Baksmali is an assembler / disassembler for for dex file format.
Input and Output
Since Smali and Baksmali is used to work on dex file format, input is obviously .dex file. .dex file is packed (you can say zipped) under android apk or .jar file. Generally named as “classes.dex”.
When you baksmali (disassemble) it, the tool will disassemble and extract all the classes present in the dex file. Practically you will not get files under .class extension. Rather you will get .smali files, in which you will get code in form of dalvik opcodes or smali syntax.
Learning smali syntax can be time consuming but it can be a bliss for android developers.
Smali-Me! – Custom made Smali / Baksmali batch tool.
I have coded a tiny tool that automatically baksmali .dex files and later smali them.
How to disassemble or baksmali?

- Download Smali-Me! tool. Extract it somewhere (say C:/Smali-Me-1.0)
- Place .dex file in that folder.
- Run baksmali.bat
- You will get disassembled files in folder called “Decompiled”
- Make your edits carefully.
How to reassemble or smali?

- Copy all the content from folder “Decompiled”
- Paste it in folder called “Smali-Me” (if folder does not exist, create a new one)
- Run smali.bat
- If no errors found, you will find a file called “modded-classes.dex” in root folder.
Caution : Make sure there is ONLY ONE .dex file present in root folder. If there are more than one .dex files are present, this tool won’t work.
I hope this tool will make your development easier. Good luck with your development..
Regards,
Rahul
Apktool does this automatically
Sir, Apktool decompiles apk and framework. You need smali, baksmali tool in order to disassemble (decompile) .dex file structure if you want to work on classes.
Apktool helps to extract .dex files though. 
Appreciate your reply though!
Good to find an expert who knows what he’s tiaklng about!
Decompile any apk or jar with apktool and the output will be and has always been a smali folder (decoded dex).
So enlighten me
Same here sir, I am also a ROM developer.
Well, you can definitely decompile jar and get .smali with apktool. But I would recommend using smali / baksmali.
I used to decompile jar files with apktool. It decompiles jar files very well but compilation is still buggy with apktool. Smali files got corrupted during compilation and it broke the jar file.. Any way which version of apktool do you use?
I am developing a GUI tool that ease the process of apk and framework engineering. Right now I am using apktool 1.5.0 which is stable enough!
Thanks for your reply sir, appreciate your participation
This article is served to teach how to work with .dex files so I believe this tool is good enough to teach beginners. I prefer working with AOSP and CM10 sources though.
Using own compiled apktool.
And have no clue what u mean by corrupting the files.man
Been working for 30 months like this via terminal command and never had issues and probably never will.
Apktool was restructured a year ago or something to work with classes.dex.
Dont want to downgrade ur work but its a bit obscelete
Many .smali files were of size 0kb. Probably they were corrupt.
Which was creating issues while recompiling it again. May be there was a issue with apktool version I was using. I stopped building my own apktool way back 
Anyway, I will check that stuff and update this article with apktool method as well
Thank you for your response.
Strange issue there….
Working in windows ?
Was working on Linux before, then I shifted to Windows, Lots of Visual Studio work needs to be done here
Anyway, which ROM do you cook?
AllianceROM
Anyhow its a good iniative you have here , will keep checking in how your site will develop itself
Robbie my friend.. You remember me right? I am “Rahulrulez” / “Rahul++” from XDA, DarkyROM forums
Nice to see you again. Thanks for visiting my site
I appreciate your comments. Keep in touch.. Good luck with your development. I am out of SGS development. I am getting a new phone very soon. Will kick start my development on my future phone 
Yeah i remember you
what phone are you planning to get ?
Umm, haven’t thought of it so far! May be I will get SGS3 in next month
FllashYou must be sure to copy the framework-res.apk from the ROM you will be woikrng with into the same directory as APKTool.Then issue the command: apktool if framework-res.apkAfter this, you should be free to decompile any apk coming from the ROM you are woikrng with and not encounter any issues.
Hi Rahul,
Thanks for sharing this info. I am trying to edit one of the java file inside apk and recompile back to apk. I was able to decompile apk properly and create project of it. But when i import it into eclipse it shows many errors and after looking into java file, i realized the resource (R file) reference is replaced with constant number and few variable names had changed. So i couldn’t able to edit required java file.
Is this possible to edit those java file without any error and recompile back to apk or i need to edit the smali file itself. Please help me on this and let me know which will be best approach to process it.
Thanks.
Can you please share the apk file? I will look in to it.