What software do I need to decompile a apk? - Java for Android App Development

I need a program to decompile a apk for cm7, to make a rom and my question is what program do I need? from already thank :laugh:

frixed said:
I need a program to decompile a apk for cm7, to make a rom and my question is what program do I need? from already thank :laugh:
Click to expand...
Click to collapse
Try this guide: http://forum.xda-developers.com/showthread.php?t=1989533

you mean like extracting the files from apk file...........you can always use 7zip or winrar
it will extract the file in it like as if unzipping any file.....there you will find the xml files and any media and metadata folder dont know what else

you can use ApkMultiTool to decompile, edit, sign and install apks

apktool & the likes will generate smali code, which is a real mess. Here's how you should proceed to get readable java sources from an apk (for educational purposes only!)
Use apktool only to extract the /res folder from an apk
Extract the classes.dex from your apk (either with an archive manager or in terminal with the following command) :
Code:
unzip yourapp.apk classes.dex
Download dex2jar, put your classes.dex in the same folder and cd to it, then :
Code:
bash d2j-dex2jar.sh classes.dex
Download JD-GUI, put it in the same folder as dex2jar & classes.dex and cd to it, then :
Code:
./jd-gui classes.dex.dex2jar.jar /[COLOR="Green"]/or whatever the generated .jar file's name is[/COLOR]
This will open the jd-gui IDE with all the java sources of your apk, hit source/export all sources (or something like that, I don't remember exactly)
Add the /res folder you extracted with apktool to the /src folder you extracted with dex2jar/jd-gui and import the whole thing as existing Android code into Eclipse
There you go, you now have a full eclipse project out of an apk, the decompilation might have generated a few errors in the code during the process though, you'll need to fix them to be able to rebuild the apk.

Related

CrunchIT Method

A Type of COMPRESS EXTENDED ROM that uses the SelF eXtracting Archive (SFX), done thru a Zip Program(Pocket Rar, Winzip, or Winrar), Zip it then Make a SFX with Nsctech CrunchIT 5.0, then add the XdA2JoJo.v3.0.1t.CAB in config.txt to automatically execute the ExtROM.exe and extract the files to TEMP folder, the files will be executed by autorun and needed to specify the \TEMP\ as the path, after installing all program files, it will remove the cab files in the TEMP folder with wei's Fast Cleanup 1.3
.. for more details about the CrunchIT Method Click Here

[Q] Recompile XML's?

Hello, i have decompiled an app using apktool which had some errors and im missing the apktool file so i cant re-compile it, however the XML's are readable and i have made some tweaks.
Is there any other way to convert the human readable XML to android binary code?
I tried AXMLPrinter2, but it cant compile the XML
The only way I can think of to do this without apktool is to build a dummy project in eclipse, then add your xml to the project, and export it. You can then extract the xml byte code from the apk.

Rom Release Guides

This is a helping guide from think i learn all this time editing and publishing roms here for U8800pro it isnt something great but i think it will help a lot of people who want to start with easy thinks
Programs and files that you need
Download Java JDK 7u2
Download Cygwin_Packages.zip
Download Android Kitchen Version 0.207
Download ApkTool 1.5.0
Download zip_signer
Download baksmalimanager
Download 7zip
Download Notepad++
The first and most importand thinks to have so you can cook a rom is Cydwin Kitchen!
So what do you need to start your setup!​
Download Java JDK 7u2 : Latest Java Development Kit at the time of writing. You can download most recent version here.
Download Cygwin_Packages.zip : Cygwin packages with setup file for offline installation. The Cygwin tools are ports of the popular GNU development tools for Microsoft Windows. For more info on Cygwin read here.
Download Latest Android Kitchen Version 0.207 : Latest android kitchen at the time of writing. You can look for a much recent version at dsixda's Github.
So, once you have got the required files. Follow the steps below carefully to setup Android Kitchen on your PC. Want more details? Watch this video I did on installing Android Kitchen on Windows PC.
1. Install latest Java JDK. It's pretty simple just follow the instructions and you are done.
2. Download and Extract Cygwin Packages and Android Kitchen on your desktop or somewhere easy to access.
3. To begin, install Cygwin first. So, run setup.exe from the extracted files and go through the installation process.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
4. Choose install from folder not from internet and choose the folder that you extracted on your desktop then click the round icon until it says install next to it!
5. Run Cygwin.exe from desktop once and it will create a folder with your username on /home/ directory.
6. Navigate to the folder where you installed Cygwin and go inside .../home/yourname/ folder.
7. Copy the Android Kitchen Version 0.207 to this location.
8. Run Cygwin.exe and navigate to kitchen folder. for that simply type the command cd kitchen and press Enter.
9. Once inside kitchen folder, type ./menu to run android kitchen. Note: if you get a permission denied error then type chmod +x menu or chmod 777 menu in Cygwin command line utility first and then only run the command ./menu .
10. You will be presented with the Android Kitchen menu seen above. Use these options and get started.
So you have a working cygwin application to be able to let you cook your roms
Now lets use this app​
1) Run Cygwin.exe from desktop
2) Wait the terminal to show you your name above and a $ character then type ./menu and press enter
3) Wait for the kitchen to load you will se the menu of the kitchen
4) Now we have to put our base rom on the kitchen folder example c:\cygwin\home\(yourpcname)\original_update folder
5) After adding the zip rom to this file press 1 on the kitchen menu
6) Read and follow the info on the kitchen until it extract the files to c:\cygwin\home\(yourpcname)\WORKING_xxxxxx_xxxxx (x is numbers)
7) In this folder you will have an extracted contents of your rom do anything you like change apk's change libs change what ever you wan't
8) After editing your rom, you can test other features of the kitchen too like adding root or like adding init.d support, press the 99 command on the kitchen
9) The kitchen then will begin to build your rom press the 1 when it ask you its a interactive method to build your rom it will ask you to zipaling your apk's press Y and then wait for the rom to build on the folder c:\cygwin\home\(yourpcname)\OUTPUT_ZIP
10) Your rom now is ready to release with one more think to do...cos kitchen is made for HTC phones the META-INF folder is made for a HTC phone you need to take the META-INF folder from the previous zip rom... (of course is a working for your phone rom) and paste it in the new zip kitchen made for you
Voila you have a working freshly cooked rom from kitchen put it on your sdcard and test it before publish it on the forum!
Now we have to use ApkTool, The latest ApkTool is 1.5.0 and you can download it from here
Apktool lets you de-compile and compile apk's so you can edit them for example you can de-compile your framework-res.apk so you can change the battery icon remember that many thinks to change you need to edit a bunch of xml's too!​
So the apktool is a simple tool nothing too dificult and strange
1) After downloading the zip extract it to a folder no in your desktop is good to have all your programs to a specific folder so you dont have to search but its a personal choice
2) The first think to do is to register our systemui.apk and framework-res.apk to the apktool so it can find the strugture of the files we edit
3) Remember that those too files are for a specific phone not for all android phones cos not all android phones uses the same systemui and framework-res
4) So we need to take our two this files from a working rom for our phones and put them to our windows folder (Yeah the exact folder that have your windows in it)
5) We also need the two files inside the apktool zip too...so all the 4 files the two from the zip and the two apk's from our rom to put them on windows folder
6) After that we need to register them through CMD
7) The easiest way to do it is from inside the windows folder with pressed shift and left mouse click to choose open command window here
8) Be sure that the path of the cmd will be C:\Windows just to be sure and then we need to type apktool if framework-res.apk & apktool if systemui.apk we will see after each command that the cmd will tell us that the 1.apk and 127.apk are register on c:\users\......\apktool
9) Now that we have our apk's register we can edit our apk's
10) Now close the window folder we finish from here and open your folder that have the working apktool in it
11) Just like before press shift and left mouse click to open command promp
12) You need to put at least on apk that you need to edit inside apktool folder
13) In the command type apktool d nameoftheapk.apk
14) Wait for the decompile to finish and you will have a folder with the name of the apk that you decompile
15) Inside this folder you will see the contents of the apk you just edit the most easy think to change is the png's the png's are inside /res/drawable-hdpi
15*) Remeber that when you edit an apk to make a mod just like move statusbar clock to center or make transparent status bar use the exact steps that you find here on xda on a tutorial you will find don't just change png's and xml's the sure think is that after finishing this the apk will give you a lot of FC's!
16) Anyway after changing whatever you want inside the apk go again to the command promp window and type apktool b nameofapk (without the .apk extension) nameofapk2.apk! INFO:You dont need to put the apk extension in the first part cause you now compiling the folder not the apk and then you need to add a 2 or 3 or test after the name of the apk so it didn't cause problems with the existing apk with the same name!
17) Your apk is now ready remember that sometimes the apk will be smaller on size if this is happening the compile is faulty mostly cause resources.arsc didnt copy in the new apk or some times most of the times if it is a system apk like systemui.apk or settings.apk you need to open the original apk and took the META-INF folder and the androidmanifest.xml and paste them to your new created apk!
Now we need the zip_signer. The zip_signer tool is a simple tool that you can sign your roms without having to put them on the kitchen only for signing its quite simple to use
​
1) Download zip_signer from here
2) Extracted to a folder on your pc and open the application
3) Drag the rom that need signing and press sign then wait for the app to finishing and then you will see a newly created zip on the same folder this is you new sign rom ready to use!
INFO: So now what is sign and why we need it..remember when you trying to install a rom that the cwm sais (bad) this is an unsign zip sing need to verify the files in the rom and to see that they have the same key...also remember that you need to sign a rom when you just edit apk's through winrar on winzip kitchen always sign a rom when cooking it!!
One more came to my mind is the smali/backsmali editor
Smali files are files inside an apk and/or a jar file in our roms that we need to decompile from apk/jar edit and the recompile it an example of editing a smali file is smooth scrolling and patched services on ICS/JB for memory optimise with supercharger​
1) First of all again you need to download baksmalimanager from here
2) Also like the apktool this is an easy tool to use extract it on a folder to your pc
3) Open the baksmali Manager.bat ignore the adb error press enter and in the interface choose 4
4) There is no need to say that you already have your apk/jar file in the same folder with baksmali Manager choose it on the interface
5) Then press 1 and wait for the tool to baksmali the apk/jar file
6) When it finished dont close the manager you will see a folder named after the file you just baksmali open it made tha changes again unter a tutorial and then go again to the baksmali Manager
7) After finishing editing the smali files and you are back on the baksmali Manager choose 2 and wait for the tool to smali the apk/jar that you just edit
8) The diference with apktool is that after the tool is finished smaling the files it will extract a classes.dex in the folder you have the tool
9) This is the compiled smali files you just edit take this classes.dex file and put it in the original apk/jar that you baksmali in the first use 7zip cos is the best for this thinks after droping the classes.dex file to your apk/jar file you are ready to put the new file in your device for testing!
Thats for now more as i remember to come!!
Bump may need who knows!!
Nice Guide Ill follow this weekend.
pika the ultimate uot kitchen si 208 not 207 and there are a lot of other tool to unpack file .smali to unpack update.app
mauronofrio said:
pika the ultimate uot kitchen si 208 not 207 and there are a lot of other tool to unpack file .smali to unpack update.app
Click to expand...
Click to collapse
I dont update kitchen if its an update you can update inside kitchen...also i know there are a lot of tools to unpack a update.app but kitchen is the easiest!!this is a help guide to start with no to read it and then go to work to google!
Update links please.
Umm Ok pika i used this guide to port and few more stuffs *Stalker!!* lol. Well add this to requirements!
1)Android SDK for ADB
We need this to take logcat when the rom we made is not booting .
And moreover NEVER EVER LET kitchen make a kernel for you! It screwes up! I was porting DesireHD pacman onto My CM10. kitchen just swapped ramdisk and the phone was stuck on Huawei Logo. Next i pulled out battery tried to go to Recovery to restore found out alls gone so it was a bluescreen. So remember this when you make rom out of Dsixda's kitchen change the META-INF folder and chnge the BOOT.IMG.
Ramdisk and init.rc doesnt allow htc roms to boot on our phone.
And I think Ivans 6.0 recoery could be used to Mount our U8800pro im the kitchen directory i kinda did it.
-Rik[Rittik]

[Utility][Tool]baksmali/smali

- What is baksmali/smali?
smali/baksmali is an assembler/disassembler for the dex format used by dalvik, Android's Java VM implementation. The syntax is loosely based on Jasmin's/dedexer's syntax, and supports the full functionality of the dex format (annotations, debug info, line info, etc.)
The names "smali" and "baksmali" are equivalents of "assembler" and "disassembler" respectively.
- Author of the tool
JesusFreke
- Why we need it?
Android apk and jar files will include java classes to execute certain functionality. With baksmali, you will be able to disassemble the java classes into editable form (smalis) so you can do your editing and modding involving java script. Once you done changing, you need to assemble all classes to a readable form for android, i.e, classes.dex and here comes the role of assembler (Smali).
Since we have apk manager, do we still need this tool?
Yes and No!!! Because some apk managers even if they do support jar files but once they decompile smalis, they will remove some lines (.line, .parameter, ...etc) which are in my opinion are useful to locate some codes. So the choice is yours.
- What does this tool do?
Simply it baksmali classes.dex of android apk and jar files into editable form (smalis) to do your changes; then assemble it back (smali).
- Will it affect apk and jar original signature?
No, it will preserve original signature.
- Got problem?
During assembling (smali), you may got error message. You can check log file to locate what is wrong that make the manager stop assembling the file or post the log file for developers to look into it.
- What are the steps to work with this tool?
Run Baksmali_tool.bat file, this will create all needed folders in the first run.
1. Put android apk or jar file in "put-file-here" folder. If Current-file status is set to None, then either you need to set a file in option #3 or you forget putting valid file in "put-file-here" folder.
2. When Current-file status is set to your file, you can disassemble its classes.dex by option #1.
3. Classout folder with name of file project will be created in "project" folder; make your changes there.
4. If finished your changes, assemble classout folder by option #2.
5. If everything is OK, a new file will be created in "finish" folder with tag (Modded_) in its name, push it to your device by option #3 if it was system apk or jar; and if it was non system apk file, install it by option #4.
- Latest stable version
Latest stable baksmali/smali version: 2.2.2 (30.10.2017)
baksmali v. 2.2.2 - Download (bitbucket.org)
smali v. 2.2.2 - Download (bitbucket.org)
baksmali/smaly previous versions - Download (bitbucket.org)
- Latest beta version
Latest beta baksmali/smali version:
- Changelog
baksmali/smali wiki and changelog (github)
- Where can I download latest source code?
You can visit
baksmali/smali source page (github)
and you can download the latest smali and baksmali code versions.
- Special Thanks to XDA Portal Team
Special thanks to XDA Portal Team for featuring this utility
XDA Portal Team
..
hi m8,
thanks for this nice tool
will try it next time I make a new theme
sent from my G-Note
great work majd keep it up
no credit to the author of smali/baksmali? :/
iBotPeaches said:
no credit to the author of smali/baksmali? :/
Click to expand...
Click to collapse
I think the authers are these guys ([email protected], [email protected], JesusFr.. @gmail.com) from project page.. aren't they??? if so I will update OP
majdinj said:
I think the authers are these guys ([email protected], [email protected], JesusFr.. @gmail.com) from project page.. aren't they??? if so I will update OP
Click to expand...
Click to collapse
Yes, thats the same person. I'd just put JesusFreke, as thats his username.
Version 1.1 is online
version 1.2 is online
some bugs fixed
Grate dev, Great tool...tnx majdini:fingers-crossed:
What a great idea to simplify life ^^.
Thanks majdinj.
majdinj said:
Backsmali / Smali Manager​
What is Backsmali / Smali?
smali/baksmali is an assembler/disassembler for the dex format used by dalvik, Android's Java VM implementation. The syntax is loosely based on Jasmin's/dedexer's syntax, and supports the full functionality of the dex format (annotations, debug info, line info, etc.)
The names "smali" and "baksmali" are equivalents of "assembler" and "disassembler" respectively.
Why we need it?
Android apk and jar files will include java classes to execute certain functionality. With backsmali, you will be able to disassemble the java classes into editable form (smalis) so you can do your editing and modding involving java script. Once you done changing, you need to assemble all classes to a readable form for android, i.e, classes.dex and here comes the role of assembler (Smali).
Since we have apk manager, do we still need this tool?
Yes and No!!! Because some apk managers even if they do support jar files but once they decompile smalis, they will remove some lines (.line, .parameter, ...etc) which are in my opinion are useful to locate some codes. So the choice is yours.
What does this tool do?
Simply it backsmali classes.dex of android apk and jar files into editable form (smalis) to do your changes; then assemble it back (smali).
Will it affect apk and jar original signature?
No, it will preserve original signature.
Got problem?
During assembling (smali), you may got error message. You can check log file to locate what is wrong that make the manager stop assembling the file or post the log file for developers to look into it.
What are the steps to work with this manager?
Run Backsmali_tool.bat file, this will create all needed folders in the first run..
1. Put android apk or jar file in "put-file-here" folder. If Current-file status is set to None, then either you need to set a file in option #3 or you forget putting valid file in "put-file-here" folder.
2. When Current-file status is set to your file, you can disassemble its classes.dex by option #1.
3. Classout folder with name of file project will be created in "project" folder; make your changes there.
4. If finished your changes, assemble classout folder by option #2.
5. If everything is OK, a new file will be created in "finish" folder with tag (Modded_) in its name, just rename it to its original name and push it to your device; don't forget to fix permissions as well.
If backsmali and smali code are outdated, what to do?
Just visit codes owner page, and download the latest smali and backsmali code versions and put them in "tools" folder (make sure to rename them to baksmali and smali without version number)
Future development?
Feel free to report any bugs or suggestion to improve upcoming releases :good:
Download
- Backsmali-Manager_v1.2 @ 11/June/2013 (The most recent one)
- Backsmali-Manager_v1.1 @ 7/June/2013 (old)
- Backsmali-Manager_v1 @ 6/June/2013 (old)
Change-log:
@ 11/June/2013 (v1.2):
- Fixed bug of file path in Read Log option.
- Fixed number 10 file that was not shown in Set Current-file option.
@ 7/June/2013 (v1.1):
- Deleting the folder and file in project and finish folder of same project name before backsmali or smali (no more overlapping :fingers-crossed.
- Added Read log file functionality in the main menu.
- Ability to open classout folder after backsmali.
- Ability to open finish folder after smali.
- Ability to renamed finished modded file to its original name.
- Neat smali and compression processing (i.e, hidden processing ).
- Fixed set Current-file option to visualize only apk and jar files.
@ 6/June/2013 (v1.0):
- First release of Backsmali / smali manager
Click to expand...
Click to collapse
i don't know how to start editing this smali file
badagila said:
i don't know how to start editing this smali file
Click to expand...
Click to collapse
Editing smali means to modify your jar or apk file to do certain new function, check the second thread in my signature in OP... you will find a lot editing tutorials of smalis of some android apps :laugh:
majdinj said:
Editing smali means to modify your jar or apk file to do certain new function, check the second thread in my signature in OP... you will find a lot editing tutorials of smalis of some android apps :laugh:
Click to expand...
Click to collapse
ok dude thanks
Hi, your work is featured here: http://ajqi.com/baksmali-smali-manager-windows-tool/
Keep it up!
VERY NICE!
Good Work..
I dont know much about smali backsmali.. but one confusion..
Is this tool also applicable if the files (apks or jars) we want to modify are odexed?
OJ said:
Good Work..
I dont know much about smali backsmali.. but one confusion..
Is this tool also applicable if the files (apks or jars) we want to modify are odexed?
Click to expand...
Click to collapse
No, actually classes.dex are made from the odex files.
If files are odexed, then there will be no classes.dex in apks or jar files. That's why it won't be applicable then
Version 1.3 is online
Change log:
- Added adb push finished file to device system partition (for system files).
- Ability to choose whether to reboot device after pushing files to device.
- Added adb install finished apk (for non-system files).
- Adjustable Java heap memory size.
- Adjustable finished file compression level.
- Updated Smali and Backsmali codes (date 15/6/2013).
@ 23/June/2013 (v1.4):
- Added Pull apk or jar From Android Device to the main menu.
- Added zipaligning process during Smali (better RAM management).
- Fixed apk installing process (added signing process step for installing apk process).
- Added direct link to this xda page in update option.
- More script polishing...
@ 29/June/2013 (v1.5-FINAL):
- Fixed adb remount bug for some ROMs in push option.
- Baksmali argument is updated; now you can choose whether to baksmali with x argument (retain .line, .parameter, .prologue, and .local) or b argument (remove .line, .parameter, .prologue, and .local).
Hi,
i've XP&Backsmali / Smali Manager v1.5 and i want baksmali framework.jar but i got error message(attachment)
I think wrong is slash (should be a backslash)
the same error is after i select 1(baksmali*)and then x and Y or
--------------------------------------------------------------and then b and Y
*baksmali or backsmali?

[TOOL][GUI][Reverse engineer] Decompile APK to JAR Full Decompile :: One Click

Reverse engineer "Perfect software" , managed to convert apk to a jar file and decompile it using JD(via dex2jar)
The program uses 3 tools (apktool.jar, dex2jar.bat, jad.exe)
I've updated all lib/scripts ,apktool.jar 1.5.2, dex2jar 0.0.9.15
in attach you will find
Fragment.apk I've tested with this tool and works fully !!,look on OutPut_Fragment.zip to see the result
Download:
DeCompileAPK.zip
To Start
Works on Windows7/8
1. Scan dir for “apk” file or look for the file with “APK File Directory”.
Scan has a “subfolders” flag ,in the “Options” tab.
2. Double click on the found file it will be transferred to the “APK File Directory”.
3. Write or look for the output directory. Leaving this line empty will put all
the project output files under the directory “OutPut” where this program is executed.
If there is an output directory name, a directory “OutPut_” + APK file name
will be created.
3. Press the Decompile KEY.
4. All Dos messages will be seen in the “Decompile OutPut” panel.
5. It will be shown also in the “Edit log” panel.
6. The log can be edited and printed.
7. A java file editor is included. Scan project files, Scan any directory or open any file.
NOTE : USE ONLY ENGLISH CHARACTERS FOR FILE NAMES !
Credit and Thanks !
Tool Dev Website: http://www.limelect.com/android/
Reversed for new stuff
anyone tell us how it works with him?
codexc said:
anyone tell us how it works with him?
Click to expand...
Click to collapse
no download link to test

Categories

Resources