[Q] help editing classes.dex - Android Q&A, Help & Troubleshooting

First, my native language is not English, sorry.
I have been trying to modify the classes.dex in a specific app, can't manage it well.
First of all, extract classes.dex from apk and chage it to smali file(use baksmali).
Second, modify smali file, and then turn it back to classes.dex.
Finally, compress classes.dex into apk.
However, android cut off as soon as play after installing apk.
I thought how about if do not modify the smali file. So, No sooner had i transform dex into smali than retransform smali into dex. but it still not working after install. transformed dex's binary is even different from original dex's binary. Why is this happening?
Plz. Help me....

Related

[Q] Decoding and re-encoding apks with APKTOOL

So I've decoded a launcherpro apk and gotten all the files inside.
I've edited them changing only some images(not .9.pngs) and some text strings for a translation.
I don't really know how to re-encode the file and sign it.
I tried using APKtools to repack but ASTRO won't let me install it saying it can't open it as an apk file.
Any help is appreciated
i cant get apktools to do anything other than decompile...
if you got it to compile your apk but dont know how to sign it, use this: http://androidforums.com/developer-101/8665-how-signing-roms.html
its what i use to sign zips and apks and it works very well and is easy. the "auto sign" or qwhatever opetion doesnt ever work for me, but option 4, manual, works fine
if you havent installed the framework-res.apk that may be why you cant compile
what you need to do is pull out the framework-res.apk and put it in you root directory then in terminal use this.
code: apktool if framework-res.apk

Problem modifying apk

Hi, i am trying to modify the classes.dex file in an apk but it is giving me problems.
if i decompile the apk and recompile it after modifying the app installs but crashes after one minute. also some functionality in the app is also lost.but when i binary edited the classes.dex file and replaced it in the apk ( i have used different methods for replacing the .dex such as direct replacing in archive and replacing in the decompiled archive) the app doesn't install and the phone or emulator reboots. i have done this with other apps and they are working fine after editing so i couldn't understand what's going wrong. please help
You should use a decompiler and achive to the java code. Than you can easily modify and recompile the app. You will need an Linux virtual machine to do this.
In linux, after you found you .apk file use this to decompile it to a .jar file. http://siis.cse.psu.edu/ded/installation.html. After that, you can use http://java.decompiler.free.fr/?q=jdgui to browse the code. With this method you will need a Linux machine and would give you the best result.
If you want to use windows, follow this tutorial http://androidorigin.blogspot.com/2011/02/dex-format-to-jar-format.html but I warn you, its likely to be faulty.
Hope this will help you.
thanks for replying
i used apktool to decompile and modify the smali code. i had even tried converting the smali code to java but no help.the problem is that the recompiled app runs only for one minute and then crashes without any error message even logcat log is not of help it just says that the process xxx has died but no err msg or exception is logged. if i replace the classes.dex with the patched one and then re-sign it it does not install and crashes the emulator but when i again decompile and then recompile the modified file it return to the same old problem of crashing. do you know how apktool packages the compiled files?
You should follow one of the tutorials posted in my last post. I did not used apktool and I don't know how it works.c the method with that decompiler will work. If you want your application signed just sign it as a normal one.
this particular apk loses about 20-30 kb in filesize on decompiling and then recompiling with apktool while this is not seen in any other apk. maybe this means that this file has some overlay data that goes missing on modifying and creats problems.7-zip is unable to show any extra data in the file.does anyone know how to add and extract overlay data on/from an apk?

[Solved] smali changes not compiling

I don't know if I'm doing something wrong or missing a step but I'm trying to get my status bar transparent following this guide
http://forum.xda-developers.com/showthread.php?t=1523703
I'm using wanams apk manager, I make the changes to the statusbar.smali file and the xml files, I compile and it doesn't work on my phone, so I decompiled the modified apk, and the changes to the xml files went through but the smali files go back to the originals.
when compiling I use yes on Is this a system apk, yes to copy additional files, go to keep, delete resources.arsc and finish.
It happens with any smali file when I compile, I use notepad++ to edit the files.
Solved: So what I ended up doing since my xml files were saving but my smali files weren't, kindof a noob so I didn't realize that when compiling it asks to copy over files and the classes.dex file was overwriting all my changes to the smali files, so I compiled and when it asks to delete files from the keep folder I took the classes.dex from that folder, decompiled it seperatly made the changes to the smali files there. I still deleted my resources.arsc, then I finished making the apk opened the apk and replaced the classes.dex there with my modified one. pushed to my phone and everything works perfectly.
I don't know how it works for other files but try applying the same method somehow; When decompiling and recompiling framework-res.apk, there is a resources.arsc file that is created and placed inside a build folder under the original decompiled folder. Drag that resources.arsc to the NEW apk file you have, and it will work.
I assume you're decompiling a .jar file so maybe it's a classes.dex file. If there is a newly compiled one under some build folder, try placing it into the new .jar file. Make sure the compression method is STORE, or 0 if it's a scale. Try out some combos until it works out.
liinko said:
Solved: So what I ended up doing since my xml files were saving but my smali files weren't, kindof a noob so I didn't realize that when compiling it asks to copy over files and the classes.dex file was overwriting all my changes to the smali files, so I compiled and when it asks to delete files from the keep folder I took the classes.dex from that folder, decompiled it seperatly made the changes to the smali files there. I still deleted my resources.arsc, then I finished making the apk opened the apk and replaced the classes.dex there with my modified one. pushed to my phone and everything works perfectly.
Click to expand...
Click to collapse
Just delete the classes.dex from keep folder and press enter in apk manager menu.. and you're done
?
systemui with smali
in the whole forum not an any solution for compiling with smali

Apk multi tool shuts down when decompiling

Hi, I recently wanted to try some apk editing, and when I try to decompile one particular apk file, apk multi tool immediately shuts down after inputing command for decompiling.
I tried different apk files, and they are decompiled without problem, but it still won't decompile the apk I wanted in first place.
ps: sorry if posted in wrong section/forum

[JB]Xperia Sola 6.2.A.1.100 SemcPhone.apk Compile

Hi there,
I am using 6.2.A.1.100 Rom from DeathZeroFX on my Xperia Sola and I want to change the semcphone.apk caller image size.
I am using APK MultiTool v5.5.7 but although I am able to decompile it with no errors when I try to compile it, it keeps running forever. I have "installed" framework-res.apk, semcgeneric....apk and from folder (system/app) the systemui.apk.
I tried Apk MultiTool v4 and I got the same error with this http://forum.xda-developers.com/xperia-u/issues/decompile-semcphone-apk-t2118131.
All I want to do is change a value inside res/layout/somc_incallscreen_large.xml.
Even if I make no change same thing happens (v5.5.7) does not give me any error just keeps running..
In the decompiled)apk folder I get a new folder called "build" and inside there is only the classes.dex nothing else!
Searching the web does not say anything particular except for old aapt.exe version
I am desperate I even tried to compile the helloworld.apk (found on web which (de)/compiles with no problem) and just add my res folder but of course that could not happen.
Any suggestions?Or even another tool?I need to edit those @#$% android binary xmls..
Bingo
Despite being desperate, I used APK Studio and after decompiling I modified some of the xml, plus with the help of the previously decompiled java classes and the help of notepad++ I changed the corresponding code inside smali files and then build it. After that I copy pasted the edited files (from the apk) into the original one without signing and yeahaa happy reverse engineering..If I sign them with APK Multitool it will crash..(Though it is not clear if it should be signed again (for me crashes), somewhere says that by restoring the original META-INF and Manifest.xml will do the job (which does for me since the final apk is the original just with modified classes.dex).
I have a semcphone.apk with callers image (scaled down a little bit) instead of being cropped.
The last alternative was editing binary files through notepad++ hex editor which is a no go..

Categories

Resources