December 5th, 2012, 12:56 AM
Thread Author (OP)
Join Date: Aug 2010
Device(s): LG Motion 4G
Pirates are people who attack ships. People who share software are good neighbors.
Thanked 402 Times in 170 Posts
[GUIDE]Disassemble/Assemble smali code on your Android device
I inquired irc #smali about disassembling/assembling apk's directly on an Android device. I decided to post this because I'm not familiar enough with the terminology to know exactly what JesusFreke is saying. But maybe someone can put it to good use.
<Sepero> Hi :)
<Sepero> I was just wonderig if there was convenient way I could install the disassembler/assembler on my android device.
<DAGr8> sepero not a bad request
<DAGr8> but what woudl be the use of this ?
<DAGr8> make mods straight fromthe phone ?
<DAGr8> assembling some jars takes some ressources
<DAGr8> depending on your phone it could be way to long to do
<JesusFreke> you can do it, but yeah. memory is an issue :)
<JesusFreke> baksmali is doable. smali is questionable for larger apks
<JesusFreke> This should be improved quite a bit with the rewrite of dexlib that I'm doing
<JesusFreke> but that's still likely a month or two out
<JesusFreke> If you want to try it, just dx the baksmali or smali jar, and then stick the classes.dex back into the original jar. alternately, add the classes.dex to a new zip file, and add the smali.properties or baksmali.properties from the original baksmali or smali.jar
<JesusFreke> then, on the device
<JesusFreke> dalivkvm -cp /sdcard/baksmali.jar org.jf.baksmali.main
<JesusFreke> if you're running on a newer device (I think maybe ICS+), and don't have root access, you may need to create a dalvik-cache dir somewhere, and specify the ANDROID_DATA env variable
<JesusFreke> mkdir /sdcard/dalvik-cache
<JesusFreke> ANDROID_DATA=/sdcard dalvikvm -cp /sdcard/baksmali.jar org.jf.baksmali.main
<Sepero> Does "dx the baksmali or smali jar" mean to turn it into an .dex file?
<JesusFreke> dx is the tool in the android sdk that converts java class files into a dex file
<JesusFreke> dx --dex --output=classes.dex baksmali.jar
Last edited by Sepero; December 6th, 2012 at 09:31 AM.