[How To]: Decompile / Compile .APK - Hero, G2 Touch Android Development

Source Found
Brut.all of XDA has released the program APKtool which make the process of editing any APK file much easier, especially XML editing. Before you had to use a few different programs (Smali, hex editor, etc) to do the same thing. A future release is going to have the decompiler dump into an easy to import into Javabeans/Eclipse format.. so nice
Program and Usage link;
APKTool 1.2
Setup;
Before you start, download from the link above both the apktool-1.2.0.tar.bz2 and apktool-install-windows-2.2_r01-1.tar.bz2 and extract them to your windows folder.
Usage;
Decoding APKs;
Code:
apktool d <file.apk> <directory to output to>
Compiling APKs*;
Code:
apktool b <directory of decoded apk>
*The compiled apk will be saved to the sub directory "dist", which is in what ever directory you choose to compile.
Output structure;
Smali directory - The output of classes.dex, the code to the apk
Res directory - Your resources, the images and layout/structure xmls
Lib directory - Shared library files
Dist directory - The apk output of the "apktool b" command, if you didn't run it you won't have it.
Build directory - The compiled output of the "apktool b" command, like what you would see if you just extracted an apk file with 7zip. If you didn't run it you won't have it.
General info;
Once you have your edited apk from the Dist directory you'll need to sign it. I use Dave Da illest 1 of XDA's modified script for signing. Just place your apk, this should be the only apk in this folder, in the same folder that you extracted the auto-signer to and execute sign.bat. The script will output your_app_signed.apk, which is your signed and ready to load on your phone apk.
If you'd like to decompile/compile an apk file that doesn't have a classes.dex, like framework-res.apk, just place any classes.dex into the apk and it will decompile. If you don't do this apktool will through up an error. Just remember to pull the classes.dex out before you sign it.
Videos;
Editing an Apk file with APKTool;
http://www.youtube.com/watch?v=XXgYVHTcl6c
Editing a Jar file with APKtool;
http://www.youtube.com/watch?v=VAekeWiqHcY
Why?;
Localization / Translation
Themeing
Adding in features or taking them out
Impressing friends and family, lol
etc..
Issues;
I noticed that while the new version 1.2 works great on the framework-res.apk file, it seems to have issues with other System/app files like Settings.apk,Phone.apk, etc. For these files use version 1.1.1.
Hopefully this is helpful, I tend to ramble.
-Ften @ sdx-developers.com

http://forum.xda-developers.com/forumdisplay.php?f=613
Post it here too, mate.

shokkapic said:
http://forum.xda-developers.com/forumdisplay.php?f=613
Post it here too, mate.
Click to expand...
Click to collapse
Will do, not having a good time at the moment as I can't seem to edit launcher.apk with this tool. Not sure why. basically I decompile, edit then compile but having issues when transferring it back to the phone.
EDIT: I just get a black screen when trying the new modified .apk file.

Why to create new threads, if apktool has its official thread here
http://forum.xda-developers.com/showthread.php?t=640592
andrewb84uk said:
Will do, not having a good time at the moment as I can't seem to edit launcher.apk with this tool. Not sure why. basically I decompile, edit then compile but having issues when transferring it back to the phone.
EDIT: I just get a black screen when trying the new modified .apk file.
Click to expand...
Click to collapse
Do you get any errors in logcat?

Brut.all said:
Why to create new threads, if apktool has its official thread here
http://forum.xda-developers.com/showthread.php?t=640592
Do you get any errors in logcat?
Click to expand...
Click to collapse
I could not find it anywhere else and I did do searches for hours Brilliant tool!
See Attachment, I think it's this line
Code:
E/PackageManager( 138): Package com.android.launcher signatures do not match the previously installed version; ignoring!
However, not sure how to fix it.

andrewb84uk said:
I could not find it anywhere else and I did do searches for hours Brilliant tool!
See Attachment, I think it's this line
Code:
E/PackageManager( 138): Package com.android.launcher signatures do not match the previously installed version; ignoring!
However, not sure how to fix it.
Click to expand...
Click to collapse
Not an expert. But try to uninstall the previous launcher, before installing that one.

shokkapic said:
Not an expert. But try to uninstall the previous launcher, before installing that one.
Click to expand...
Click to collapse
Will try it.
EDIT: Nope, uninstalled re-installed, still black screen.

andrewb84uk said:
I could not find it anywhere else and I did do searches for hours Brilliant tool!
See Attachment, I think it's this line
Code:
E/PackageManager( 138): Package com.android.launcher signatures do not match the previously installed version; ignoring!
However, not sure how to fix it.
Click to expand...
Click to collapse
I think you can't install Launcher just like that, because it's system app. You should do it through update.zip file.
Try to not use apktool, but just unpack Launcher.apk, remove META-INF dir, zip it back, sign and install. If you will get similar problems, then they can't be related to apktool (because you didn't even use it), but to something else.

Brut.all said:
I think you can't install Launcher just like that, because it's system app. You should do it through update.zip file.
Try to not use apktool, but just unpack Launcher.apk, remove META-INF dir, zip it back, sign and install. If you will get similar problems, then they can't be related to apktool (because you didn't even use it), but to something else.
Click to expand...
Click to collapse
If I unzip it, remove META-INF dir, zip it back, sign + install and it works fine. It doesn't work when I edit 1 file by decompiling and compiling, sign, upload it fails but it also fails using APKManager.
EDIT: I have also tried using notepad++ / notepad to edit the xml both to the same issue.

Err... you know, your problem is for sure related to signing/installation and not to apktool. Key error line is here:
E/PackageManager( 138): Package com.android.launcher signatures do not match the previously installed version; ignoring!
Click to expand...
Click to collapse
andrewb84uk said:
If I unzip it, remove META-INF dir, zip it back, sign + install and it works fine. It doesn't work when I edit 1 file by decompiling and compiling, sign, upload it fails but it also fails using APKManager.
Click to expand...
Click to collapse
Could you explain, how is it possible, that you can properly sign rezipped apk, but you can't reapktoold' one? If you get signing issues, then this is totally irrelevant what apktool does. All files could be random binary strings as well cause they aren't even read.

This thread can be deleted or moved to the bin or where ever it needs to go!

idroid84 said:
Usage;
Decoding APKs;
Code:
apktool d <file.apk> <directory to output to>
Compiling APKs*;
Code:
apktool b <directory of decoded apk>
*The compiled apk will be saved to the sub directory "dist", which is in what ever directory you choose to compile.
Click to expand...
Click to collapse
Thank you soooo much!!! It took me hours of searching to find this post and once I did, I had my apk decompressed in under a minute!!! You da man

If your running windows XP here's a right click reg edit I made for making decompiling/compiling quicker-
forum.xda-developers.com/showthread.php?t=935967

Hey guys... really trying to theme for the first time with xml files.
I have done modifying of png which are easy, but just lenghty and detailed.
So now that Gingerbread is out, some of the items have been moved to the xml files.
indeterminate was from 4 and now down to 3. but I want to increase to 8 to mimic honeycomb. Also the progress horizontal was once a png reference file now its in the systemui.apk xml too.
Anyhow short version.... anytime i edit more then 1 line at a time after decompiling, when trying to say it will ask to save as text.
Whats the best file editor for xml? or recommendations.

I use notepad++ on windows, you can also import your decompiled apk into eclipse and use that, it'll also report any errors or mistakes you might make.
Hope this helps.

Yeah I have been using that do and any time I compile and flash it just gives me boot loop.
Question about proper importing to eclips.
Whenever I just flat out decompile ... do my modification, go to recompile, it get errors. In apktool and apkmanager.
Should I extract the resource file and class dex out and then decompile. Cus when I have the resource file in the same directory....at least last nights attempt, apktool finale didn't give me an error and compiled.
I've done a decompile just from apk and imported to eclips and when I try to run, gives error.... "no style availiable" or something like that
Sent from my Droid using XDA App

Thank you!!!
Greetings.

fixing a broken abondon market apk
Could someone fix this app VirginmobileMinuitechecker . I think i found the problem . Virgin Mobile updated there site from logon www1 to www2 . I edited it from the open source and zipped it back up but i cannot get this compile program to run at all . here is the zip master . I made several attempts emailing jay goel but he his MIA .. the app will no longer log in because of the VM website recent changes . TIA
EDIT ,, NEVER MIND . i got it working and fixed that app . works like a charm now pretty good being i don't code for a living.. if you don't mind i posted the fixed app . you may move or delete if it is not proper . thank you for the tutorial .

Related

[Q] Modding CM framework-res with new battery icons.

I am trying to use percentage icons with CM nightly build. I tried to unzip it and replace icons and xml battery files but I don't get any battery icons to show up on my status bar. I was able to make my own theme by replacing icons and image files but I wan percentage battery icons. I tryied to change xml files in CM source code and recompiled it and then I gor random icons instead of my battery icons. I also tried to replace all images but then would tell me that images are missing something and will stop compile. Could somone point me the right direction on how to mod framework-res to include percentage icons
http://forum.xda-developers.com/showthread.php?t=724778
I tried it and does not work. The kitchen does wird stuff to my framework and makes the phone reboot
tritron777 said:
I am trying to use percentage icons with CM nightly build. I tried to unzip it and replace icons and xml battery files but I don't get any battery icons to show up on my status bar. I was able to make my own theme by replacing icons and image files but I wan percentage battery icons. I tryied to change xml files in CM source code and recompiled it and then I gor random icons instead of my battery icons. I also tried to replace all images but then would tell me that images are missing something and will stop compile. Could somone point me the right direction on how to mod framework-res to include percentage icons
Click to expand...
Click to collapse
In addition to changing the XML files in the /res/drawable folder, specifically:
stat_sys_battery_charge.xml
zzz_stat_sys_battery_1.xml
stat_sys_battery.xml
And adding the new png file to /res/drawable-hdpi
You MUST make sure you add resource IDs for each of your newly added png files to the /res/values/public.xml file. Otherwise, the XML has no way of referencing the new images by ID, and the likely reason why you were getting random imagines, rather than the new ones specified.
If you are manually editing and recompiling, you can then just grab the above referenced XML files and the 'resources.arsc' file from the newly built apk file and drop them in your original.
JsChiSurf said:
In addition to changing the XML files in the /res/drawable folder, specifically:
stat_sys_battery_charge.xml
zzz_stat_sys_battery_1.xml
stat_sys_battery.xml
And adding the new png file to /res/drawable-hdpi
You MUST make sure you add resource IDs for each of your newly added png files to the /res/values/public.xml file. Otherwise, the XML has no way of referencing the new images by ID, and the likely reason why you were getting random imagines, rather than the new ones specified.
If you are manually editing and recompiling, you can then just grab the above referenced XML files and the 'resources.arsc' file from the newly built apk file and drop them in your original.
Click to expand...
Click to collapse
What's the easiest way to get the resource ID's for the new images?
HeyItsLou said:
What's the easiest way to get the resource ID's for the new images?
Click to expand...
Click to collapse
Decompile an existing super battery framwork-res and pull the IDs from it's public.xml file.
You do not need to put in the ID's. You can just edit the xml files add the pics to your hdpi folder and recompile, apkmanager will make the ID's by itself.
rujelus22 said:
You do not need to put in the ID's. You can just edit the xml files add the pics to your hdpi folder and recompile, apkmanager will make the ID's by itself.
Click to expand...
Click to collapse
I don't use apk manager but I do use apktool which apk manager uses and I can verify this to work 100%
If you open say com.htc.resources.apk with an archive manager like 7zip for windows or archive manager if you're using linux and drop in your edited png's then use apktool to decompile the framework it should create all of the resource ID's in the public.xml file for you. At this point if you have any xml edits or smali edits to do complete those then recompile. Now just extract the "res" folder and the "resources" files from the compiled apk and using the same archive manager from above to open the original com.htc.resources.apk and replace the files you should be good to go.
IS there a way to autogenerate image ids?
tritron777 said:
IS there a way to autogenerate image ids?
Click to expand...
Click to collapse
Not that I'm aware of however I'm no pro themer. As far as I know you have to manually edit the xml's in the drawable directory by creating the strings that point to the drawable hdpi images you created or it won't work.
if you use http://circle.glx.nl/ you won't need to do the manual xml updating. i use this kitchen for my cm6 nightly ROM.
extract the framework.apk file from the cm6nightly that you are using (current nightly builds have had changes to the framework...thus if you flash tonight you may need to redo the process..perhaps you can just dump the updated framework and resign the zip..i just go back to the kitchen and recook) anyway..
after extract
go to kitchen
set ur desired options
upload the framework file
wait
download the UOTxxx.zip file
put on root of evo sdcard
reboot into recovery
flash the UOT zip file
enjoy
but then, that's the automated cheater way.
I suppose if you don't know what you're doing, kitchens are great. For non noobs who don't want / need to use (the whole point of the thread as the op had problems), doing it manually makes sure it is done right without making your framework all screwy.
Sent from my HTC Evo
JsChiSurf said:
I suppose if you don't know what you're doing, kitchens are great. For non noobs who don't want / need to use (the whole point of the thread as the op had problems), doing it manually makes sure it is done right without making your framework all screwy.
Sent from my HTC Evo
Click to expand...
Click to collapse
I completely agree. I rather learn how to do something the manual way it just empowers you for any future mods you may want to do. Not to mention if you rely on one resource and all of a sudden that resource such as a kitchen goes away you're out of luck.
HeyItsLou said:
I completely agree. I rather learn how to do something the manual way it just empowers you for any future mods you may want to do. Not to mention if you rely on one resource and all of a sudden that resource such as a kitchen goes away you're out of luck.
Click to expand...
Click to collapse
Completely agree, Learning how to do something is always better.

[Tutorial] Doing simple mods on framework-res.apk when apktool doesn't work properly

Hi again!
Some people asked how I did the mod I posted on the thread http://forum.xda-developers.com/showthread.php?t=1738094 and I promised I would say it.
First off, this method will require you to go deep inside binary files, so please don't try to do it if you didn't completely understand every step and know the basics about the hexadecimal, binary diffs, etc.
Before start
I will start saying what was supposed to work. You should use apktool to decode the apk, modify what you want, and then use apktool build it again. But, as of the latest version of apktool I tried (1.4.3), decode and build doesn't work for for Xperia S' framework-res.apk. (Maybe bug http://code.google.com/p/android-apktool/issues/detail?id=313 and http://code.google.com/p/android-apktool/issues/detail?id=256 are related?)
The closest I could get is using apktool 1.4.1, but the generated file was so smaller than the original and I wasn't brave enough to test on my phone.
Anyway, you will need to do this "normal" process (decode and build) for this method too. You can use any version of apktool that decode and build without errors. I used 1.4.1, but I believe a newer version could get a closer output, thus a easy file to do a binary diff. Don't worry, we won't flash these malformed apk's!
So, lets start.
PLEASE, read all the steps before start to understand the whole thing. The main idea is to find some bytes that precedes the value we want to change, then find these bytes on the original resources file and change the value we want.
1. Make sure you have adb, apktool, and everything needed on your path. I will give you the commands assuming all of them are in your path.
2. Get the necessary apk's from your phone:
Code:
[email protected]:~/Android/LT26i$ adb pull /system/framework/framework-res.apk
3972 KB/s (22227101 bytes in 5.463s)
[email protected]:~/Android/LT26i$ adb pull /system/framework/SemcGenericUxpRes.apk
4970 KB/s (2095961 bytes in 0.411s)
3. Install the apk's on apktool
Code:
[email protected]:~/Android/LT26i$ apktool if framework-res.apk nozomi
I: Framework installed to: /home/brunojcm/apktool/framework/1-nozomi.apk
[email protected]:~/Android/LT26i$ apktool if SemcGenericUxpRes.apk nozomi
I: Framework installed to: /home/brunojcm/apktool/framework/2-nozomi.apk
4. decode and build the framework-res.apk WITHOUT changing anything:
Code:
[email protected]:~/Android/LT26i$ apktool d -f -t nozomi framework-res.apk framework-res
(some lines, with warnings)
I: Done.
I: Copying assets and libs...
Code:
[email protected]:~/Android/LT26i$ apktool b framework-res unchanged/framework-res.apk
(few lines)
I: Building apk file...
5. Do the same of the step above, but CHANGING what you want before build. Pay attention to the output folder of the build, it's different from the previous step.
Code:
[email protected]:~/Android/LT26i$ apktool d -f -t nozomi framework-res.apk framework-res
(some lines, with warnings)
I: Done.
I: Copying assets and libs...
(CHANGE WHAT YOU WANT)
Code:
[email protected]:~/Android/LT26i$ apktool b framework-res changed/framework-res.apk
(few lines)
I: Building apk file...
I changed the config_showNavigationBar, inside framework-res/res/values/bools.xml, but you can try changing what you want. I recommend you to start changing one single boolean value, then you can try to do more advanced things.
6. Here starts the fun! Since we have almost the same apk file, because we built both using the same apktool version, the only different bytes must be the boolean we changed. So we can unpack both apk's and run a binary diff of the resources.arsc. I'm using the vbindiff (apt-get install vbindiff) on ubuntu, but there should be other binary diffs or hexadecimal editors. So unpack and run the following:
Code:
vbindiff unchanged/framework-res.apk_FILES/resources.arsc changed/framework-res.apk_FILES/resources.arsc
It will show you the binary representation of the two files, the changed and the unchanged. Press enter once and you will see some chars in red (if you don't see, you did something worng). These represent the changed value. It was 00 00 00 00 (false) and is FF FF FF FF (true) on the modified file. Now we can observe what we have around the value we want to changed. We need to observe because we're going to edit the original file. Note that there is a column containing a hexa sequence (27, 28, 29, 2A, 2B). Our changed value is in the same line of the 29. This is the line that starts with '0077 F500'.
Copy the text of the vbindiff, containing the changed value and everything around it, to a draft file for further reference. I've attached a print of this screen, se below.
7. Now we need to do the final ninja hit: Change the original apk. Actually, the original resources.arsc. But things are no so easy, because the value we need to change is not on the same position it was is the file we changed. If we go to the position 0077 F500, something completely diferent will be there. So we need to search for something near the value we want to change. I will search for the sequence '29 1D', which is 8 bytes before the value we want to change. Yes, it's a short sequence and will occours a lot of times, but it is the best we can use. Maybe '00 29 1D', but no more than that. Let's go, unpack the original framework-res.apk and run:
Code:
vbindiff framework-res.apk_FILES/resources.arsc
Now hit F to find the sequence, and H to Hexa sequence, and type the sequence you choose (here, '00 29 1D'). To find the next occourrence, press F, then N. Do it until you find this sequence in a similiar way of the original file, having one line below with 2A, and below 2B etc. It should be near '007D C5CF'. Now you need to press E, go to the column where you have '00 00 00 00' and change to 'FF FF FF FF'. Pay attention to the other lines to change the right columns. The edited values will be in yellow. You can see the second attached print screen.
8. This is the easiest step, just copy the modified resources.arsc to the original apk. It should not be the apktool-built one, it should be the file you modified on the vbindiff editor.
I did it using the Gnome archive manager, just drag and drop the resources.arsc inside the archiver window after open the framework-res.apk.
And voilà! Your modded apk is ready!
------
Hope someone can understand this and make some mods. I did my best to explain what I did, but it's a really hard procedure thus not easy to explain.
If you have any doubts, just post and I will try to answer!
And if you like, click thanks to me!
as far as i know SemcGenericUxpRes.apk is odexed, this doesn't affect the process?
iBotPeaches has taken over development of apktool. The development thread is here:
http://forum.xda-developers.com/showthread.php?t=1755243
The latest version seems a lot better than 1.4.3
---------- Post added at 10:36 AM ---------- Previous post was at 10:35 AM ----------
Yakandu said:
as far as i know SemcGenericUxpRes.apk is odexed, this doesn't affect the process?
Click to expand...
Click to collapse
i believe only the code is odexed so you can make changes to the resources without breaking the odex file.
Frist thanks to brunojcm for share this tutorial
finally with this tutorial i could make smaller on screen buttons .
Install via CWM : Smaller On Screen Buttons.zip
Tested on .58 stock rom
Some mods by me SHOULD come tomorrow after school. Nothing big, just a few things.
Sent from my LT26i with Tapatalk 2
Soheil_rf said:
Frist thanks to brunojcm for share this tutorial
finally with this tutorial i could make smaller on screen buttons.
Install via CWM : Smaller On Screen Buttons.zip
Tested on .58 stock rom
Click to expand...
Click to collapse
Cool you understood it!
What did you change to accomplish that? just booleans or integers too? were they easy to find?
brunojcm said:
Cool you understood it!
What did you change to accomplish that? just booleans or integers too? were they easy to find?
Click to expand...
Click to collapse
after enable navigation bar in bools.xml you can change size of bar in dimens.xml ( navigation_bar_height and navigation_bar_width )
Soheil_rf said:
Frist thanks to brunojcm for share this tutorial
finally with this tutorial i could make smaller on screen buttons .
http://img818.imageshack.us/img818/1254/screenshot2012080916234.png
http://img195.imageshack.us/img195/8084/screenshot2012080916240.png
http://img402.imageshack.us/img402/2717/screenshot2012080916242.png
Install via CWM : Smaller On Screen Buttons.zip
Tested on .58 stock rom
Click to expand...
Click to collapse
How you made that? I get confused on the file comparing thing... Or you just have to decompile, change the DPI and compile back?
Your file works fine on .452 firmware. However, it has some icon bugs on status bar (the USB connnection and debugging ones) and the carrier name stays a little over where it should be.
Felimenta97 said:
How you made that? I get confused on the file comparing thing... Or you just have to decompile, change the DPI and compile back?
Your file works fine on .452 firmware. However, it has some icon bugs on status bar (the USB connnection and debugging ones) and the carrier name stays a little over where it should be.
Click to expand...
Click to collapse
Try to reading Tutorial again , its simple but gets some time
maybe you are using moded SystemUI.apk or .58 FW had some difference
here its normal
Soheil_rf said:
Try to reading Tutorial again , its simple but gets some time
...
Click to expand...
Click to collapse
Could make your mod, Felimenta97?
brunojcm said:
Could make your mod, Felimenta97?
Click to expand...
Click to collapse
Nope. Always something Ib my way. Was replacing the resources.arsc after I rebuild the app. But I read I have to replace the Meta-Inf and Manifest.xml. But now no time.
Sent from my LT26i with Tapatalk 2
You wont be able to recompile and use the same apk that's the entire point to this article and getting around this limitaion.
Simply put hex edit the resources.arsc after binary dif finds the changes integers and replace with the original in the framework-res.apk.
-smc
somemadcaaant said:
You wont be able to recompile and use the same apk that's the entire point to this article and getting around this limitaion.
Simply put hex edit the resources.arsc after binary dif finds the changes integers and replace with the original in the framework-res.apk.
-smc
Click to expand...
Click to collapse
Well, I see. I'm just trying to see what would be the effect of setting True to the Animate Screen Lights line on bools.xml I'm no developer, just a simple user trying to do some mods by myself
Sent from my LT26i with Tapatalk 2
Felimenta97 said:
Well, I see. I'm just trying to see what would be the effect of setting True to the Animate Screen Lights line on bools.xml I'm no developer, just a simple user trying to do some mods by myself
Sent from my LT26i with Tapatalk 2
Click to expand...
Click to collapse
What was it supposed to do?
brunojcm said:
What was it supposed to do?
Click to expand...
Click to collapse
As far as I know, it's the responsible for the screen off animation, at least on GB.
Sent from my LT26i with Tapatalk 2
Don't get discouraged, i've never tried to play with the screen animations but maybe there's something else you need to find/edit? Seems like a fairly small change you tried to make.
If it's not a small change not being able to recompile the framework-res file makes doing more advanced mods frustratingly impossible, i've got several mods waiting to go for our phone when we're able to.
-smc
I want to try myself some mods too. 30 volume step, Sense multitasking, etc. And it compiles perfectly (except when it says that there it's something that it's missing a translation, a file I didn't even touched). One day, when I have more time, I will try to do such things, slowly.
Sent from my LT26i with Tapatalk 2
Why to use apktool instead of 7zip?
I tried replacing a .png in framework.res and get errors.
Erachter said:
Why to use apktool instead of 7zip?
I tried replacing a .png in framework.res and get errors.
Click to expand...
Click to collapse
Because it involves a lot more than just removing files
Sent from my LT26i with Tapatalk 2
Thanks to iBotPeaches the latest custom build of apktool is now out:
[UTIL][Sept 2 2012] Apktool v1.5.0 - a tool for reverse engineering apk files
A new version has been released!
v1.5.0 (Released September 2 - 2012 ) Codename : Pikmin
Fix for colours being decompiled with improper hex colours
Fix for <string-array> being treated as array on occasion
Support for Mac OS X user:home, instead of dumping frames into /home
Updated internal framework.jar to API16
Added <user-sdk> reading to insert into apktool.yml to help with aapt building
Supported -d mode
Added --verbose mode to output contents of AAPT (note this is a HUGE output). Only used for debugging.
Ignore bootclasspath on debug mode. (Causes some classes in smali to be fail decompile)
New AAPT (Linux only) - http://miui.connortumbleson.com/othe...apt/linux/aapt
Get the patched aapt.
@Felimenta97 if your getting the language error it should be normal depending on what framework you are using, single language is never set for a multilanguage firmware.
-smc

*{HOW TO}{TEAM REJECTS}{Windows} Quick DECOMPILE/COMPILE - Jelly Bean updated 7/1/13

TEAM REJECTZ QUICK JB FIX
If anyone was having a problem with adding the 15 toggles, now just pull the classes.dex file out and quick baksmali/smali to fix it. Even though it
compiled correct it still didn't lol if you get that, but now its fixed
Since i did this for the E4GT i figured i would do the same. Well since the bean is here​
1. You need to make sure you have the latest java
2. Download Notepad++ (google it) lol
3. Download the Team Rejectz Quick JB Fix (the latest one) which is linked below
Instructions Decompile/Recompile​
1. UNzip and place the JB Quick Fix Folder on your c: drive and name it apktool
2. Since this is TW/CM10 you should drag your framework-res.apk, twframework-res.apk, and systemUI.apk onto the apktool-if cmd file
3. Now time to decompile. You can actually drag your apk from where ever its located but i suggest you place them in the Quick Fix folder.
and drag and drop it on top of the Quick-Deompile cmd file
4. To get an error less decompile i prefer you to use the stock apk
5. Once the decompile process is done. you can go into the apks folder that was created and make your edits with notepad++
warning if you create to many edits that would cause and error. then begin the process over but do them one by one​
6. Now its time to recompile ^^^^^^^^^remember the warning^^^^^^^ drag and drop the apks folder on top of the Quick-Recompile cmd file
7. Now once your done go into the apks folder you should see dist folder. Your new compiled apk is located there. I prefer to just use the build folder and drag the things I need into the apk. Much easier. Also remember if any images has been added you need to make sure you drag the new arsc file because the public.xml may have been changed
8. Don't worry about signing the apk. All of your edits besides the ones in drawable folder will be in the resource.arsc file
9. Drag that file into the apk thats in the rom your editing
10. If you decide to edit the decompressed .9 images you can check my Team Rejectz Theme Cheat Sheet located >>>Here
Baksmali/Smali​
1. Grab the apk/jar file you want to edit
2. Drag the classes.dex file out of the apk/jar file
3. Drag and drop the classes.dex file onto the Quick-Baksmali cmd file
4. A smali folder will be created
5. Now you can make your smali edit inside of the smali folder and close and save them.
6. After the edits and save, drag and drop the smali folder on top of the Quick-Smali cmd file
7. You should now see a new file called new-classes.dex. rename it to classes.dex
8. Finally drag the classes.dex file into the original apk/jar you pulled it from
If this helped you in anyway just hit that thanks button thanks!!!!!!!!!!
Download:
Team Rejectz Quick JB Fix 2.5
Change Log
Quick Fix 2.5
Faster Compile times and Less errors
Updated to apktool 1.5.2, left the older ones in
Updated aapt to most recent
Updated baksmali/smali to 2.0
Thanks for sharing man.
dazednconfused said:
Thanks for sharing man.
Click to expand...
Click to collapse
No prob. Besides I know a lot of people like simple and it couldnt get any simpler than this lol
Sent from my SPH-L710 using xda premium
Thanks for sharing the knowledge!! this should be stickied!!
im going to try this i would like to contribute to the community thanks for the (tut)
Thanks fpr sharing... unfortunately i cant get it to work...
not sure what I am doing wrong.
i grabbed the 3 files from the zip, moved them to a folder on my desktop, then dropped them in the apktool-if cmd.
then grabbed the systemui, and dropped on the quickdecompile cmd, and nothing is happening.
what else do I need to do?
Thanks again for the tool, hope I can get it working...
joshbeach said:
Thanks fpr sharing... unfortunately i cant get it to work...
not sure what I am doing wrong.
i grabbed the 3 files from the zip, moved them to a folder on my desktop, then dropped them in the apktool-if cmd.
then grabbed the systemui, and dropped on the quickdecompile cmd, and nothing is happening.
what else do I need to do?
Thanks again for the tool, hope I can get it working...
Click to expand...
Click to collapse
Put the folder on the root of your c: drive and name it apktool.
Sent from my SPH-L710 using xda premium
lorjay589 said:
Put the folder on the root of your c: drive and name it apktool.
Sent from my SPH-L710 using xda premium
Click to expand...
Click to collapse
got systemui decompile, but with errors, brut.something. tried recompiling, but still errored, even without making any changes.
joshbeach said:
got systemui decompile, but with errors, brut.something. tried recompiling, but still errored, even without making any changes.
Click to expand...
Click to collapse
If you worked on a ics rom and you did the apk-tool if then you need to do the jelly bean frame. But if thats not the case post a pic of your error so I can tell you whats wrong
Sent from my SPH-L710 using xda premium
good share of tools
thanks
15 toggle classes.dex figured out and updated. now just pull the classes.dex out and use the quick smali and baksmali
lorjay589 said:
15 toggle classes.dex figured out and updated. now just pull the classes.dex out and use the quick smali and baksmali
Click to expand...
Click to collapse
Nice. Where are all the Rejectz threads here? We got mijjah representing? whats going on up in the S3 section.. Do I really have to go out and buy another phone just to put some awesome stuff here?
I keep getting this error when trying to decompile SystemUI.apk
Code:
[*] SystemUI.apk
decompiling SystemUI.apk...
I: Baksmaling...
Exception in thread "main" java.lang.RuntimeException: bad magic value: 64 65 78 0a 30 33 36 00
at org.jf.dexlib.DexFile.(DexFile.java:377)
at org.jf.dexlib.DexFile.(DexFile.java:274)
at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:44)
at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:33)
at brut.androlib.Androlib.decodeSourcesSmali(Androlib.java:68)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:85)
at brut.apktool.Main.cmdDecode(Main.java:128)
at brut.apktool.Main.main(Main.java:65)
is there anything I can do to fix this?
Nevermind, I don't think I need it. Pretty sure I can do it in 7.zip
Stryke_the_Orc said:
I keep getting this error when trying to decompile SystemUI.apk
Code:
[*] SystemUI.apk
decompiling SystemUI.apk...
I: Baksmaling...
Exception in thread "main" java.lang.RuntimeException: bad magic value: 64 65 78 0a 30 33 36 00
at org.jf.dexlib.DexFile.(DexFile.java:377)
at org.jf.dexlib.DexFile.(DexFile.java:274)
at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:44)
at brut.androlib.src.SmaliDecoder.decode(SmaliDecoder.java:33)
at brut.androlib.Androlib.decodeSourcesSmali(Androlib.java:68)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:85)
at brut.apktool.Main.cmdDecode(Main.java:128)
at brut.apktool.Main.main(Main.java:65)
is there anything I can do to fix this?
Nevermind, I don't think I need it. Pretty sure I can do it in 7.zip
Click to expand...
Click to collapse
did you do the apktool-if instructions. and also, if this problem continues. drag out the classes.dex file and it will decompile. and use baksmali to decompile the classes.dex file
lorjay589 said:
did you do the apktool-if instructions. and also, if this problem continues. drag out the classes.dex file and it will decompile. and use baksmali to decompile the classes.dex file
Click to expand...
Click to collapse
Found my error. In the install process I went A.D.D. and added an extra directory so nothing wanted to work properly. Fixed the directory and now the SystemUI.apk decompiled correctly, thank you for this tool :good:
Stryke_the_Orc said:
Found my error. In the install process I went A.D.D. and added an extra directory so nothing wanted to work properly. Fixed the directory and now the SystemUI.apk decompiled correctly, thank you for this tool :good:
Click to expand...
Click to collapse
ok cool no problem, and remember its best to make changes 1 by 1, and compile. so you could no each and every error. it also tell u what went wrong so read it carefully. it would also tell you which line in a xml is causing problems
updated
lorjay589 said:
updated
Click to expand...
Click to collapse
Damn got to wait til i get off work to flash
mighty S3
---------- Post added at 05:02 PM ---------- Previous post was at 05:00 PM ----------
kilawayne said:
Damn
mighty S3
Click to expand...
Click to collapse
mighty S3
I love how noob friendly everyone is here..... Not a noob to rooting/flashing etc.... But actually changing stuff myself...... Total noob
Sent from my SPH-D710 using xda premium
Since this thread was dug up I just want to say that's an awesome little guide for decompiling lol. Just what I have been looking for.
Sent from my SPH-L710 using xda app-developers app

[Share Latest Apktool 4.2.2/Guide/Tutorial/] How to Decompile/Compile/Sign Apk/Jar

How to Decompile, Recompile & Sign apk
This Guide/Tutorial for Windows user
Requirement :
1. Android SDK, you can download from here (this including Java)
2. Download Latest Apktool 4.2.2 (Including Sign & baksmali) from here (this Support All apk from GB/ICS/JB 4.1.2/4.2.2)
3. Notepad++ for your tool editing xml/smali you can download from here
If you already download/Installed Android sdk/java & Notepadd++ you just download Latest Apktool 4.2.2
Download Latest Apktool, extract to :
Windows XP : C:\Document and setting\folder your computer name
Windows 7 : C:\user\folder your computer name
copy your apk & framework-res.apk/SemcGenericUxpRes.apk/framework 2 to same folder with apktool
Now you can start Editing apk
Example Editing Walkman
Open Command Prompt (CMD)
to decompile :
Code:
apktool if framework-res.apk
apktool d semcmusic.apk ( can be whatever name you give to your apk )
Some Original system apps need installed framework 2 like on stock ROM (SemcGenericUxpRes.apk)
Example
Code:
apktool if framework-res.apk
apktool if semcgenericuxpres.apk
apktool d semcmusic.apk ( can be whatever name you give to your apk )
You can start editing as you want
to recompile :
Code:
apktool b -f -d semcmusic.apk ( can be whatever name you give to your apk )
If done, you can exit CMD
open original SemcMusic.apk using Winrar or 7zip go to folder semcmusic>dist, open semcmusic.apk using Winrar or 7zip
Drag & drop folder META-INF & Lib in original apk to Modified apk, set compression to store and click ok
to sign :
Move apk modified from folder semcmusic>dist to same folder with apktool
Open Command Prompt (CMD)
Example
Code:
java -jar SignApk.jar testkey.x509.pem testkey.pk8 semcmusic.apk semcmusic_signed.apk ( can be whatever name you give to your apk )
NOTE : Sign apk only for apps 3rd Party but you can use for system>app but not all apps
to zipalign :
Open Command Prompt (CMD)
Example
Code:
zipalign -fv 4 semcmusic_signed.apk semcmusic_signed_zipaligned.apk
How to Decompile/Recompile Jar/Editing classes.dex
Copy Jar file to same folder Apktool
Example
framework.jar
to decompile :
Open framework.jar using Winrar or 7zip and extract classes.dex
Drag & drop classes.dex to Quick-Baksmali (CMD)
if done, you can find folder classes-out
now you can start editing smali file using Notepad++
to recompile :
Drag & drop folder classes-out to Quick-Smali (CMD)
if done, you can find New file "new-classes.dex"
rename file to classes.dex
Open framework.jar using Winrar or 7zip
Drag & drop file classes.dex modified to framework.jar using Winrar or 7zip set compression to normal
Credits :
Thanks to Brut.all for apktool
Thanks to Yorzua for Sign apk tool/file
Thanks to Team Reject for Quick baksmali/smali file
NOTE : If you get error when compiling, don't blame me lolz it's your mistake when editing apk
Great Guide Rizal. I am sure many were asking for it.
great tut but can you add some screens/screenshots
auni said:
Great Guide Rizal. I am sure many were asking for it.
Click to expand...
Click to collapse
Thanks, yeah some user confusing editing apk, so i share latest apktool with easy guide
Mtakween said:
great tut but can you add some screens/screenshots
Click to expand...
Click to collapse
Later i will add screenshot for this tutorial
thx nice guide
Sent from my LT26i using xda app-developers app
No doubt.. Its a great guide for some one like me.... Will sit today night and going to learn.... Thanks a lot..
From My Xperia S With XTX7 ROM
now bookmark it!! thanks dude!! :good:
thanks
Thanks for the credits, buddy
nice share there
Great guide Rizal. Decent English too. Lol. Proud to be Sundanese..
In my opinion, there are other more simplified tools that utilized apktool better (I use apkmultitools and vts (virtuous ten studios)) but people needs to know the basic right..
And I think, you need to put the java\bin directory in Path in windows system variables (or Java_home in win8). And it's better (I think) to put sdk directory (adb, fastboot), apktool and the smali jars files in the Path too, so that users can access from any folders/directory.
Sent from my LT26i using Tapatalk 2
WahyuAndri said:
now bookmark it!! thanks dude!! :good:
Click to expand...
Click to collapse
:thumbup:
Yorzua said:
Thanks for the credits, buddy
nice share there
Click to expand...
Click to collapse
Thanks for your support my friend
m1st3r1 said:
Great guide Rizal. Decent English too. Lol. Proud to be Sundanese..
In my opinion, there are other more simplified tools that utilized apktool better (I use apkmultitools and vts (virtuous ten studios)) but people needs to know the basic right..
And I think, you need to put the java\bin directory in Path in windows system variables (or Java_home in win8). And it's better (I think) to put sdk directory (adb, fastboot), apktool and the smali jars files in the Path too, so that users can access from any folders/directory.
Sent from my LT26i using Tapatalk 2
Click to expand...
Click to collapse
Yeah I know, but some user will confusing lolz, this apktool is latest version so will work for apk 4.2.2, old version doesn't work
:thumbup:
Sent from my Xperia V using Tapatalk 2
I've seen other guides say that resources.arsc should be copied from the old apk and stored in the new one.... is that necessary?
thanks =)
THANKS:good::laugh:
Why So Serious? said:
I've seen other guides say that resources.arsc should be copied from the old apk and stored in the new one.... is that necessary?
Click to expand...
Click to collapse
Can anybody shed any light on this?
Hey rizal, following your decmpile/recompile method, the apk wont install, signature problem.
zhuhang said:
Hey rizal, following your decmpile/recompile method, the apk wont install, signature problem.
Click to expand...
Click to collapse
There are some problems when signing the apk. The workaround for this: use some tools (ticklemyandroid does good jobs) to completely signing the apk (I've done this when modifying systemui.apk), you can also learn from it (learn some of its codes). Or just move files that u've modified from the modified (recompiled) apk to original apk (7zip is your friend)
Why So Serious? said:
I've seen other guides say that resources.arsc should be copied from the old apk and stored in the new one.... is that necessary?
Click to expand...
Click to collapse
I don't think it's necessary. But keep in my mind my post above. So it's like u keep the old resource but put the modified (and compiled) files to the original.
Sent from my LT26i using Tapatalk 2
m1st3r1 said:
There are some problems when signing the apk. The workaround for this: use some tools (ticklemyandroid does good jobs) to completely signing the apk (I've done this when modifying systemui.apk), you can also learn from it (learn some of its codes). Or just move files that u've modified from the modified (recompiled) apk to original apk (7zip is your friend)
Click to expand...
Click to collapse
Just moving with normal compression?
zhuhang said:
Just moving with normal compression?
Click to expand...
Click to collapse
Yes. Just move it to one 7zip window to another one...
Sent from my LT26i using Tapatalk 2

[Q] Decompiling and building SystemUI.apk

Okay, so I am trying to get the navbar working on the Samsung Galaxy Note 3. Pretty much, I have a feeling that SystemUI is missing the icons for the navbar, which causes it to crash when the build.prop has the line "qemu.hw.mainkeys=0". The SystemUI has all the other files that were required for the S4 sysui mod, except for the icons. Being a noob at this, I went ahead and tried to add the icons, but my apk resulted in "System UI has stopped.".
So I decided maybe I am doing something wrong. So with Android Multitool for windows, I installed framework-res.apk, SystemUI.apk, and twframework-res.apk. Next I select the SystemUI.apk for decompiling, and decompile it. Then I simply select the decompiled directory (didn't modify anything!), and recompile it. I then open the new SystemUI.apk in 7z and add the META-INF and AndroidManifest.xml from the old SystemUI.apk. I then select the newly compiled SystemUI.apk for signing, then I sign it.
This is just decompiling, then building the same thing without modifications. SystemUI.apk before decompiling is 2.7 MB, the newly compiled one is only 2 MB! Something is missing out of the new one, but when I compare them in 7z, the only thing I can see that is different is the packed size; whereas the old one has files and folders that take up more space packed than the new one.
When I try doing this with just apktool and cmd, I get java errors like crazy, and the whole SystemUI.apk ends up only half decompiling.
Any idea what I am doing wrong?
Your best bet would be to copy the log to pastebin, and post it in the apktool support thread. Get more views there for sure. Which version of apktool are you using? Can you decompile and recompile anything? Also, if you want post your systemui up and i could see if I can get it to work, narrow it down to a problem on your end that way.
Sent from my SM-N900T using Xparent Skyblue Tapatalk 2
This is my first time doing this, so of course I make a noob mistake! I thought I had to sign ALL apks, but this is a SYSTEM app, and I don't sign it. All is well! Thanks for the reply. I also updated my apktool to 1.5.2, so that may have helped too.
all you have to do is add a + before the @ sign in the line that is giving you errors....umm depending if it is xml errors....
post the errors.....
gakio12 said:
This is my first time doing this, so of course I make a noob mistake! I thought I had to sign ALL apks, but this is a SYSTEM app, and I don't sign it. All is well! Thanks for the reply. I also updated my apktool to 1.5.2, so that may have helped too.
Click to expand...
Click to collapse
You don't need to sign it? I have also this problem. It gives me error that SystemUI has stopped.

Categories

Resources