[INFO]Editing system files (smali,dex,apks) - Galaxy Ace S5830i General

NOTE: If you want to edit framework-res.apk or systemui.apk, follow this guide, it's the best available:good:
http://forum.xda-developers.com/showthread.php?t=2086771
Now, lets start
smali, dex....whaaat?
It's simple our odexed ROMs have .apk which use .odex files which contain cache. When the ROM is deodexed the .apk contains classes.dex which now contains information present in the .odex files!:good:
Smali is nothing but disassembled .dex file! The .dex file is disassembled into java code which can be edited via Notepad ++( simple notepad works too)
WHY?
Why do you need to edit classes.dex !
For me, i was trying to make CRT on/off animation which required editing classes.dex in service.jar!
More edits where classes.dex inside services.jar is needed
- Changing status bar clock color
- Changing text color in notification bar
- More? Tell Me!:highfive:
HOW?
Requirements: Java SDK!
I have APK Multi Tool, although it decompiles .apk and .dex files inside the apk, it doesn't provide option to decompile a separate classes.dex!
Still it's best software for decompiling apks and more!
Smali-Me 1.0
Download and Instructions:
http://www.wrapcode.com/android/baksmali-smali-dex-files/
ROM Tools by iamareebjamal - More noob friendly
http://forum.xda-developers.com/showthread.php?t=2163286
Once you have decompiled classes.dex, you'll get various folder with various files. Edit the files required and then recompile!
So after generating new classes.dex, put it back to services.jar by opening the file in winzip!:good:
ONE MORE THING
Make your own flashable zip
The recompiled systemui.apk or framework-res.apk, when pushed via root explorer give lot of force closes. This is normal, however if u wish to avoid it u can create a cwm flashable zip for the same!:good:
I'm attaching the sample.zip here and u can add your files in the specified folders. For more details read the source forum:
http://forum.xda-developers.com/showthread.php?t=1721680

Reserved- for more stuff!

Subscribed.. will see what it is later

Hey, add this to your guide, i far more easier and nice to look at too than smali me
http://forum.xda-developers.com/showthread.php?p=40435351#post40435351

Related

combine same jar files

hi guys,
i am looking for way to easily "combine" multiple same jar files.
one example: i want to use 2-3 mods which are in services.jar but when i overwrite this file with another services.jar in /system/framework i always have only one mod logically.
so i can't use "trackball notification", "battery percent" and "browser mod" together.
i found way how to do but it's not easy. i unpacked jar and got classes.dex which i dedexed with baksmali and got many smali files then i combine the changed files from all mods and combine them via smali back to dex file and pack them back in jar file.
is there easier way to do it?
Use the diff command, using logical attributes (otherwise as soon as you see some new code, the rest that follows may make you believe there is something new)
And write your own Jar file
then post it back up here for us all to use; including the mods you've installed...
Mostly, though, I would say this belongs in a different forum
houmles said:
hi guys,
i am looking for way to easily "combine" multiple same jar files.
one example: i want to use 2-3 mods which are in services.jar but when i overwrite this file with another services.jar in /system/framework i always have only one mod logically.
so i can't use "trackball notification", "battery percent" and "browser mod" together.
i found way how to do but it's not easy. i unpacked jar and got classes.dex which i dedexed with baksmali and got many smali files then i combine the changed files from all mods and combine them via smali back to dex file and pack them back in jar file.
is there easier way to do it?
Click to expand...
Click to collapse
Your only other option would be to download the aosp source and compile the changes in yourself. Most of these changes are already in cyanogen's latest github.
The browser one is the only one i'm not sure of

framwork-res.apk modifying

Hi,
i'am searching for a guide how to manipulate correctly the framework-res.apk.
All ways i have tested fails.
I would modify some symbols in Notification bar (battery 1%) but all Time the my Phone run into bootloop or all Application Crashes after Startup.
I've tryed Apk Manager 4.9 / and Manualy with apktool.
Help plz .....
what i did :
1-extract apk (i use 7zip/WinRAR)
2-edit/replace image file(s)
3-repack with zero compression level ('store' level)
4-sign the apk
5-replace file using apk or create flashable recovery zip.
regards.
signing the framework-res.apk will not work.. will make the device go into bootloop
what you need is extract the framework-res.apk using apktool and edit the things you want and then compile it again using apktool .... now open the original framework-res.apk and replace the file resources.arsc with the edited compiled one..
this way you will retain the signature of the original framework-res.apk
PapaDocta said:
signing the framework-res.apk will not work.. will make the device go into bootloop
what you need is extract the framework-res.apk using apktool and edit the things you want and then compile it again using apktool .... now open the original framework-res.apk and replace the file resources.arsc with the edited compiled one..
this way you will retain the signature of the original framework-res.apk
Click to expand...
Click to collapse
But when i add some new Files and Edit some XML the Sign will be Corrupted ?
no it won't...
You need to do two copies.. the original file and the moded one...
1. make a backup of the original file
2. extract the original file using apktool
3. edit and modify anything you like
4. compile the edited file
5. rename the compiled file to framework-res.zip and take the modified resources.arsc
6. using winrar or 7zip open (to view not extract) the backed up framework-res.apk
7. place the moded resources.arsc into the backed up framework-res.apk
by doing this you retain the original signature of the backed up file and not breaking it..
Thx, will test it ;-)
kowalski99 said:
But when i add some new Files and Edit some XML the Sign will be Corrupted ?
Click to expand...
Click to collapse
Android system, signs system apk's on boot, you shouldnt sign them
Sent from my Desire HD using Tapatalk
My signed apk just work well.
AFAIK, we only cant re-sign htc's apk.
PapaDocta said:
signing the framework-res.apk will not work.. will make the device go into bootloop
what you need is extract the framework-res.apk using apktool and edit the things you want and then compile it again using apktool .... now open the original framework-res.apk and replace the file resources.arsc with the edited compiled one..
this way you will retain the signature of the original framework-res.apk
Click to expand...
Click to collapse
The right approach always depends, what you want to change. There is no need to decompile, if you only change a few standard png. If you change xml in values folder like color, styles or arrays, you can certainly not delete resources.arsc - resources have nothing to do with the signature anyway. So if you want to play safe, you should insert the original Meta-Inf (signature) and Android Manifest after compile. It is also recommended to zipalign the final apk in order to reduce RAM usage.
thanks he_stheone64 for the clarification.. i reached that conclusion based on my own research on the net and yeah i used to change the XML files to add language support and that the only way that worked with me..
And be sure to have a working and up-to-date sdk before trying to use apktool...
First, using a old sdk release i got a partially working result (few graphics bugs and strange reboots), then with a badly updated sdk on top off the old i got apktool making many errors. Finally, re-installing the last sdk from start i got apktool and my resulting apk working correctly.

[Q] Proper steps for modding SystemUI?

So, I've successfully (I think) modded my own SystemUI.apk to simply just get rid of the hideous VZW 4G LTE in the notification bar. I've watched videos, read threads old and new, and still don't know for sure if I'm doing everything correctly. Not just whether I'm doing it correctly, but If I'm over doing things.
My understanding is that stock is odex. And everywhere I've read is the first step is to deodex. So I learned baksmali and deodexed SystemUI.odex. Realized nothing of these smali files needed modding for my intention, so smali'd back to the classes.dex file.
I then used apktool to decompile SystemUI.apk. Herein lies my first confusion. SystemUI.apk already contains the same classes.dex file that I deodexed in the first step above. Why is the same coding in two separate places? If it was actually an odex file structure, wouldn't SystemUI.odex only contain these files? And SystemUI.apk be absent of the classes.dex?
So I then changed the flags necessary in the bools.xml file and made some changes to the pngs to accomplish my task. Used apktool again to compile, and had my freshly and simply modded SystemUI.apk. No issues on the phone at all.
Is there anything that needs to be done after the compile? Is using the zipalign tool necessary? The only reason I ask is that when I do the check on my modded SystemUI.apk, I get errors. When I run the -f command, things get "fixed" and a second verification checks out.
Second, if the system is truly odex, do I need to odex and create a new SystemUI.odex file to "match" SystemUI.apk? Despite the fact that no coding was modified in classes.dex? I used the Auto Odexer Script to accomplish this for grins. It spit out a new SystemUI.apk and SystemUI.odex.
All three of scenarios above worked (recompiled SystemUI, zipaligned SystemUI, and odexed SystemUI). But which is the correct way?

[GUIDE] Deodex any app on android N with phone

This guide we will use systemui as an example for deodexing.
Download androblacks apktool below. Install.
Open apk and update it when prompted. go into settings. Make sure you tick "root" option at the bottom. Close the app.
Use any root file browser and create a folder on SD card called "apktool."
Go into system/privapp and copy over systemUI.apk and systemui.odex into apktool folder on SD card. Go back to system/framework and Copy over framework-res.apk to apktool folder on SD card.
Open apktool app and click on internal storage. Select apktool folder. Click on framework-res and in select install as framework. When its done select systemui.apk and also install as framework.
Once completed click on systemui.odex and select decompile for android N. When finished long press on the decompiled odex folder and select recompile. It will create a systemui.dex file. Click on the systemui.dex file and select "add to apk" option. The dex file will now be added to the original systemui.apk. to make sure it worked click on the apk file in your root browser and select view, inside you will see a classes.dex file. Use apktool to now decompile the original systemui.apk and you will now have a decompiled smali folder.
I used this method to deodex my systemui in order to make the necessary mods for 3minit battery mod.
Link to andro Black's apktool:
https://www.androidfilehost.com/?fid=817550096634742560
Hi thanks for sharing this. It seems really cool but when would this be needed? Is this supposed to be for odexed roms and what does deodexing really do anyway? Or is this just because it's possible. Thanks
Odexed applications cannot be decompiled and edited to the same level that a deodexed application can. I'm not going to go into the detailed differences between odex/deodex, a simple google search will clear that up. Odex apks are bifurcated, with odex file containing optimized code readily available for the system to use.
Anyone wishing to modify an apk, especially theming, will need to deal with deodexed files, no odex.
Pain-N-Panic said:
Odexed applications cannot be decompiled and edited to the same level that a deodexed application can. I'm not going to go into the detailed differences between odex/deodex, a simple google search will clear that up. Odex apks are bifurcated, with odex file containing optimized code readily available for the system to use.
Anyone wishing to modify an apk, especially theming, will need to deal with deodexed files, no odex.
Click to expand...
Click to collapse
Oh okay that makes sense whenever I've modified apks they've been deodexed but I've never really looked at odexed files as I'm always on a custom ROM. Thanks
Sorry for noobish questions. When finished do you recompile the SystemUi_src? Also if doing other apps do you need to install each apk as framework? The system/framework only gets done once, but if moving on to others do I need to delete the other apk that was installed as framework?
Delete

[Newbies][Documentation]What's an apk and how does it work

Quick Intro :
Let me answer that question, an apk, first of all, is the format of Android apps, as .exe would be for Windows, apk means Android Package by the way.
But what’s the big deal?
Well an apk contain a lot of things into it.
When you open it as an archive, you might get those files:
AndroidManifest.xml
assets
res
META-INF
resources.arsc
classes.dex
AndroidManifest.xml is the file that contains the information about the app itself: the list of all activities, all permissions, the name of the app’s package, and the software/hardware requirements. To be able to read it, you’ll need to decompile the apk file.
Assets and res folders are meant for resources. Most often, you won’t see the assets folder because its usage is limited, (explanations here). We’ll focus on res since asset isn’t used so often.
META-INF contains CERT.RSA and CERT.SF (certificate) as well as MANIFEST.MF (a manifest)
Those files are the app signature, and META-INF is the folder that contains signature.
The resources.arsc file is the file holding most of the resources that were originally in the res folder. After compiling the code, Android Studio (or others software) compile resources into this file. You won’t be able to open it with an archive explorer. We’ll need to decompile the apk to get the resources back into the res folder.
And, finally, the classes.dex file contains the every smali files of the app. A smali file contains the java code for a specific part of the app. To be able to have the smali files (into the smali folder), you’ll have to baksmali your app.
Hopefully, apktool (a reverse engineering tool) does it for you.
Let’s decompile the apk using apktool (a popular tool used to decompile apps):
Once apktool is installed (see the apktool web page to know how to install), you’ll need to use the command prompt to decompile the apk:
Code:
java -jar apktool.jar d [name of the apk].apk
(I advise to create a folder and to put every file needed in it: the apk, the apktool.jar file, and the apktool script).
You’ll have an out folder, and when you browse it, you’ll have most of the time:
AndroidManifest.xml
original (a folder)
res (a folder)
smali (a folder)
The AndroidManifest.xml that you see here is the translated one.
In the “original” folder rest the META-INF folder and the original AndroidManifest.xml file (untranslated). As you can guess by its name, this folder contains unchanged original files.
The res folder is now full, because every resource from the resources.arsc file are now back into the res folder
Same for the smali folder, this folder contains every piece of code contained into the classes.dex file.
We will now focus on the res folder. Now that it’s complete, we can see those folders (it depends on your apk, but here is the list of the most common ones):
anim (other animation stuff, see the links at the end of the thread)
animator (animation properties)
color (color state list: in which condition this color is used for a particular element)
drawable (can be pictures or xml files, it contains a lot of things)
layout (contains the files that define the layouts of the app)
mipmap (icons for different screen densities)
values (xml files that contains values, that will be referenced in other xml files in other folders)
xml (every other unclassified xml files)
Those folders contain files that will be named following their resource ID.
So how does all of this work together?
Well, the java code written in the smali files will call resources with their IDs. This way, the app will show you the write thing at the right moment, following the code. The layouts are already described in the layout folder. What the code really do is analyzing the action of the end user and calling other resources in consequence.
For example, I’m using the XDA Labs app on my phone. I’m in my phone’s section, and I’m about to click on a thread to open it.
I clicked on the thread, so the code loaded the thread layout with every post in it, and other resources such as the little arrows at the top to jump to the end/beginning of the thread, the reply button, its color, … That’s how to work if I want to keep it simple.
I tried, in this guide, to simplify android app basic for beginners. Feel free to ask any question, I’ll be glad to answer.
If you want to go further into it, you can read a very complete guide about app basics by google (it’s a bit complicated to read, assuming you’re just starting to understand).
Here are the links:
https://developer.android.com/guide
If you have any question about that guide, you can also ask me (with the quote you didn’t understood).
Keep at mind that mastering app basics is really important if you ever want to theme/create an app. So, this guide and the google one is a good place to start.
Have fun reading
Hello Raiz,
I decompiled the apk of an androind app from playstore using dex jar and apktool however I can't find the scripts anywhere in the resulting files. Where should I look? Or is there something more that I have to do? I'm trying to edit something for personal use to make the game more enjoyable. I saw a .unity3D file in there so I presume it was made in unity if this helps.
Good tutorial about concepts of APK file. The details you share are so educational. Thanks for sharing

Categories

Resources