Help Decompiling/Recompiling Stock/System App with APK+ODEX - Android Q&A, Help & Troubleshooting

I've got a specialized Android box running 8.1. I also have a full system image for the machine.
Within the image is a custom app that I'd like to modify. I'm able to pull the APK and ODEX/VDEX files from the priv-app folder. I'm also able to deodex to get all of the smali files, and recreate the classes.dex.
This is about as far as I've gotten. I should also say I've never done this, so may not have all the necessary tools. At this point, I'm simply trying to create a new and functional full APK that can be installed on another machine.

For anyone following....
Once you've got your dex files, add it/them to the apk package. Install Visual Studio Code (the free general use version of Visual Studio). Then install the APKLab extension. With VS open, CTRL-Shift-P to bring up the command menu, where APKLab: Open an APK should be at the top. Select it, then choose the APK to open, along with the desired options. These are what I generally choose:
-decompile_java (much easier to read the java than smali code, although it cannot be edited)
-force-manifest
-no-debug-info
-deobf
-show-bad-code
*unselect only-main-classes
Make any edits within the smali. In the left side Explorer menu, right click apktool.yml and select APKLab: Prepare for HTTPS Inspection. When complete, right click apktool.yml and select APKLab: Rebuild the APK. Your newly compiled APK will be placed in the "dist" folder.

Related

[Q/Help] How do I mod sms handling?

I got a problem with the way sms's are handled by HTC Sense(Its the HTC Desire).
I receive a sms from work on a daily basis, and thy contain a "/" (Slash as in "WorkPlaceName A/S") in the "from/sender" field instead of a phone number.
The problem is that the phone receives it, but discards it again because of the slash.
All sense based ROM's I've tried have all had this problem, but the non-sense froyo(2.2) ROM's are fine.
Now I want to change the behavior my self, but I don't know where to look.
I was thinking the kernel or somewhere in the ROM?
But I'm not sure.
I'll appreciate any help.
Anyone can help on this?
Does anyone know how would know?
Have you tried using Handcent instead of the HTC app? Since HTC's apps are not open source, it might not be easy to modify them although you could try 'APK Manager'.
Also, I recommend reading this if you want to understand how apps interact with the OS in Android - http://developer.android.com/guide/topics/fundamentals.html
gnarlyc said:
Have you tried using Handcent instead of the HTC app? Since HTC's apps are not open source, it might not be easy to modify them although you could try 'APK Manager'.
Also, I recommend reading this if you want to understand how apps interact with the OS in Android - http://developer.android.com/guide/topics/fundamentals.html
Click to expand...
Click to collapse
Yes i did try Handcent, but as far as I can see the problem runs deeper then that.
I tried almost all sms apps on the marked, and the sms's keeps getting deleted.
if there is any way to change it, you could most probably find it by decompiling the apks associated with the sms system.. Unfortunately I have no idea what file it would be, however you can convert the Android compiled XMLs with AXMLPrinter2.jar file, and edit the settings to get it to do what you want (though there is a better and more efficient way to do this.. I cant remember what the program is called to do it..)
You can get AXMLPrinter2.jar from here: Download
You have to have the java jre (java runtime environment), and here is the syntax:
1. rename the apk to a .zip file
2. extract the files to a folder
3. 1 by 1 go to the files you want and type (for example)
java -jar AXMLPrinter2.jar Rosie.xml > Rosie.txt
Like I said there is a better way. There is a program out there that will do the hard work on multiple files for you, however I can't remember the program name.
hexskrew said:
if there is any way to change it, you could most probably find it by decompiling the apks associated with the sms system.. Unfortunately I have no idea what file it would be, however you can convert the Android compiled XMLs with AXMLPrinter2.jar file, and edit the settings to get it to do what you want (though there is a better and more efficient way to do this.. I cant remember what the program is called to do it..)
You can get AXMLPrinter2.jar from here: Download
You have to have the java jre (java runtime environment), and here is the syntax:
1. rename the apk to a .zip file
2. extract the files to a folder
3. 1 by 1 go to the files you want and type (for example)
java -jar AXMLPrinter2.jar Rosie.xml > Rosie.txt
Like I said there is a better way. There is a program out there that will do the hard work on multiple files for you, however I can't remember the program name.
Click to expand...
Click to collapse
APK Manager?
hexskrew said:
if there is any way to change it, you could most probably find it by decompiling the apks associated with the sms system.. Unfortunately I have no idea what file it would be, however you can convert the Android compiled XMLs with AXMLPrinter2.jar file, and edit the settings to get it to do what you want (though there is a better and more efficient way to do this.. I cant remember what the program is called to do it..)
You can get AXMLPrinter2.jar from here: Download
You have to have the java jre (java runtime environment), and here is the syntax:
1. rename the apk to a .zip file
2. extract the files to a folder
3. 1 by 1 go to the files you want and type (for example)
java -jar AXMLPrinter2.jar Rosie.xml > Rosie.txt
Like I said there is a better way. There is a program out there that will do the hard work on multiple files for you, however I can't remember the program name.
Click to expand...
Click to collapse
Thanks I'll try that.
But do you know the name of the HTC SMS apk?
I can only find MMS and mail.
Anyway I'll have a look at the MMS apk.

[Q] Editing an APK, any APK.

EDIT: Figured it out.
Care to share?
Yeah, will be nice if you could share this information with others
aitorTheRed said:
Yeah, will be nice if you could share this information with others
Click to expand...
Click to collapse
Man, I hate it when people do that...
1. Search for APK Manager in XDA and install it on your PC
2. Download and Install the Android SDK kit on your PC
3. Follow the instructions for APK Manager and place the APK file in the modding folder
4. Open APK Manager and select Decompile APK (Your APK file will be placed in a separate folder for you to work on)
5. Change what you want to change in the APK
6. Recompile the APK and sign it (unless it's a system file like framework, those are not signed)
A lot more is involved in modding an APK file and you really should know something about how the files inside the APK work before you go changing things, but in a nutshell, that's the basics.
Hope that helps!
What I have learned.
I had a specific question, but here is what I can tell you.
1. Setup APK Manager, it saves a lot of command line typing.
2. Pretty much always use option 9 and 11, never 1 or 3.
3. If you are simply changing graphics and not smali or XML files, don't use this, open it in 7zip and drag the files. Decompiling changes the image darkness sometimes.
4. Unless you are working on your own apk file, always say yes to 'is it a system apk', when it asks you to keep existing files, say yes. Delete from the 'keep' folder what you edited.
5. If you edit XLM files, delete resources.arsc from the file, this is where they all get compiled to.
6. You can use this for jar files, just rename to apk then back to jar when finished.
7. If you get an error try using option 20 to increase the memory to 1024.
8. If you edit jar files, delete classes.dex in the 'keep' folder when compiling.
9. Treat all files as signed system files (as noted above) and you will be much safer. If the file has a signature on it, this will save it.
Thanks for the info
Is there anything that can install system files. They won't install with ap manager so does it have to be pushed?
Sent from my Desire HD using XDA Premium App

[Q] Recompiling an apk correctly

I've made some aesthetic changes i like to my GO Launcher EX apk, which is a non system apk. The change I made was to some dock images, which did not have the .9 extension. Everything goes smoothly until I try to install my compiled .apk. If i leave it unsigned, it won't install, but if i sign it, it will. However, when i open it, the screen flickers constantly and will not respond. I'm out of ideas.
FYI, I compile/decompile with Apkmanager and edit with Gimp.
If you're not doing any thing with 9 patch images than there is no need to decompile in the first place. Get 7zip on computer. Right click apk/7zip/open archive and you can navigate to Res/drawable-hdpi and you can extract the drawable-hdpi folder to desktop and do what you need to with the images (non 9's) and drag new edited images into the open 7zip window in the proper place close 7zip window. Once done you only need to use apk mananger to sign the apk and push back to device.
good day. using xda premium.

(Tool) Compare files.

First off I have nothing to do with the creation of this tool I'm merely sharing what I've found.
Anyone who has dug into smali files knows that they can be somewhat overwhelming and trying to track down a problem can be a time consuming nightmare. One thing I do to hunt down a problem is compare what I know to be working against what is broken so I was sitting here today thinking that I would write a script or create a tool to batch compare files then I said to myself "EB, you're not the first one that's wanted to do this so there must already be something." I fired up Google and sure enough there are a few. The one that I found that is free and handled my task can be found here http://www.grigsoft.com/download-windiff.htm
Quick tutorial;
1. Download the file.
2. Create a new folder (anywhere you want)
3. Extract the contents to your new folder
4. Place the items you want to compare in that folder (they can be anywhere really but it's simpler to have them in the same directory.)(For my purposes I de-compiled the classes.dex of two framework.jar files and moved the entire output files to this directory in two separate folders.)
5. Run the program
6. Select File
7. Select either Compare Directory (what I did for my purpose) or Compare files. A dialogue box will pop up where you select the 2 sources that you want to compare.
Now this tool will only output what files are changed. There are other tools out there that can do more but I like the ones that are free. At least with this I can scan hundreds of files at once and see where I need to begin
if you want to search for code in multiple files and what not else,
http://notepad-plus-plus.org/
has a great program for that
You can search inside the files of a whole folder if you want to....pretty cool

[Q] Unable to re-compile (using autoapktool / apktool)

** I dont have enough posts yet so cannot start thread in the correct section, so posted it below here in general **
I have all the content ready to add to an app and been searching for the right template and came across an app that has the look and feel I want.
I used autoapktool2.0.0 and it dissasembles the app fine so you can access the xml and other files. I am also able to edit a test apk and recompile and sign it with the above software fine. It creates 2 different folders one build which has a created classes file and one called dist that has the completed recompiled apk
however, when i try one specific apk I am able to decompile it fine, but when it comes to recompiling it after making a tiny test edit it will not do it.
I creates the classes file fine but it does not recompile the whole source files into an apk, so the dist folder is not created.
Why will it not recompile the whole thing?, is there something I am doing wrong or is the thing protected?
can someone test it for me using same methods I done and see what their result is?
(no errors were given when recompiling, it acted as if it was complete but it was not, as no apk created)

Categories

Resources