How to understand smali file - Other Tools & General Discussion

Can anybody please guide me how to read & understand android smali file.
I just decompiled an apk using Apktool which generates the smali file. This file is written in plain text but the language is not something similar to any other language. I need some guide to understand the app backend functionality. I'm just looking for some sort of Java codes in the backend.
Thanks in advance.
Sent from Nexus 4.

to_sukanta said:
Can anybody please guide me how to read & understand android smali file.
I just decompiled an apk using Apktool which generates the smali file. This file is written in plain text but the language is not something similar to any other language. I need some guide to understand the app backend functionality. I'm just looking for some sort of Java codes in the backend.
Thanks in advance.
Sent from Nexus 4.
Click to expand...
Click to collapse
Hi, .. you could have a look at this guide. It covers most of the stuff required to reverse-engineer an android application. But, be warned.. don't do any stuff that infringes copyrights of someone ... !!

Related

Howto decompile XML in resource of APK?

Hey guys, I've learnt how to decompile most of the class files through dexdump.
For details check this out:
http://zeaster.blogspot.com/2007/11/how-to-decompile-dex-file-on-android_28.html
But say I wanted to decompile edit an XML file in folder \res\xml\appwidget_info.xml and resign/package an apk file. How would I go about doing that?
I've heard something about opening it up in a hex editor and this is what I get (screenshot). I'm most interested in viewing/editing the android:updatePeriodMillis value. This is in relation to the 1x4 Calendar Widget not updaating properly. Any pointers will be helpful and much appreciated.
how to do that ??
Rotundjere said:
how to do that ??
Click to expand...
Click to collapse
read the date of the post
slap yourself
read http://forum.xda-developers.com/showthread.php?t=640592
Brut.all's apktool will decode and rebuild apks and jars
you won't get java code out of it instead you will get smali code
if only want to mess with xml's strings it will let you do that
Too funny
Effdee said:
read the date of the post
slap yourself
read http://forum.xda-developers.com/showthread.php?t=640592
Brut.all's apktool will decode and rebuild apks and jars
you won't get java code out of it instead you will get smali code
if only want to mess with xml's strings it will let you do that
Click to expand...
Click to collapse
Subtle yet absolutely hilarious.
I know even my post comes late, searched for Brut.all's apktool and seen this thread, still worth noting the humour.

Decompiler

Hello, I want to decompile my framework-res apk so I can possibly add a battery that displays percentages. Is there any program out that will let me do this?
Sent from my Xoom using XDA Premium App
Your looking for Smali/BakSmali.
No offense intended here, but the fact that you are asking tells me that you are going to need a lot of research in doing this. It's not necessarily decompiled into the most readable source code. But it's that way with most decompiling, and you probably realize that.
Also, since we don't have source code for HoneyComb, the current Smali/Baksmali implementation doesn't work well/at all for some files.
Good Luck.
Kcarpenter said:
Your looking for Smali/BakSmali.
No offense intended here, but the fact that you are asking tells me that you are going to need a lot of research in doing this. It's not necessarily decompiled into the most readable source code. But it's that way with most decompiling, and you probably realize that.
Also, since we don't have source code for HoneyComb, the current Smali/Baksmali implementation doesn't work well/at all for some files.
Good Luck.
Click to expand...
Click to collapse
No offense taken. I am in the process of teaching myself these things so Google and xda are my best friends. Thanks for the reply
Sent from my Xoom using XDA Premium App
Kcarpenter said:
Your looking for Smali/BakSmali.
No offense intended here, but the fact that you are asking tells me that you are going to need a lot of research in doing this. It's not necessarily decompiled into the most readable source code. But it's that way with most decompiling, and you probably realize that.
Also, since we don't have source code for HoneyComb, the current Smali/Baksmali implementation doesn't work well/at all for some files.
Good Luck.
Click to expand...
Click to collapse
Is it possible to read the Stat sys battery XML? I've been reading on how to decompile the files but no real help with this really
Sent from my Xoom using XDA Premium App
I use apk_manager_4.9 it may be the woosie way but it works for me. Try this thread: http://forum.xda-developers.com/showthread.php?t=695701
zone23 said:
I use apk_manager_4.9 it may be the woosie way but it works for me. Try this thread: http://forum.xda-developers.com/showthread.php?t=695701
Click to expand...
Click to collapse
Thank you, I have previously viewed that thread. There aren't really any clear cut instructions on setting it up properly. Are you able to edit the XML files contained in the drawable folder? That is all I'm interested in. I can't seem to successfully decompile the framework-res apk. Thanks again
Sent from my Xoom using XDA Premium App
I will offer to help you out.
1. Install latest SDK from http://Developer.google.com & Eclipse.
2. Search for apktool and unzip files into the SDK folder under platform_a DB
3. Buddy fix apktool with attached files. You will need to rename these files to Apktool, etc..
4. Copy framework-res.apk, systemui.apk, settings.apk, and launcher2.apk from \system + copy the odex
5. Run apktool d framework-res.apk (do this for each apk)
6. Look in the Res/drawing folders for images to mod.
Now you have the .9.png files with marks & the decompiled XML for reference.
Use Photoshop to modify the files.
Use draw9patch to compile any .9.png files
This is really important. Use 7zip or any other zip app that allows you to open and view an apk as a zip without actually unzipping it. Just copy the new photo files in and add them to an update.zip (you can download this from XDA Xoom Development thread) or use a DB to push the updated files to the Xoom.
Theaming is a subject but that's the basics. I can't upload files for newapktools.zip right now but will edit this when I get home later. Alternativly, maybe someone can post the patched up Xoom compatible apktool files. They are also in XDA theaming thread if you search.
Hth
Sent from my Xoom using XDA Premium App
nbeebe24 said:
Thank you, I have previously viewed that thread. There aren't really any clear cut instructions on setting it up properly. Are you able to edit the XML files contained in the drawable folder? That is all I'm interested in. I can't seem to successfully decompile the framework-res apk. Thanks again
Sent from my Xoom using XDA Premium App
Click to expand...
Click to collapse
Yes I can you need Java JDK installed:
http://www.oracle.com/technetwork/java/javase/downloads/index.html
Eventually you will need Eclipse and I use Gimp because its free and doesn't break any .png files.
http://www.eclipse.org/downloads/
IDE for JAVA Develpoers search youtube for a video on how to set it up for android.
http://www.youtube.com/watch?v=ZoWVeXizfbo
I use Notepad++ to edit XML
http://notepad-plus-plus.org/download
Thank you very much for that! I edited the images I want to use, I waes just trying to add the respective values into the XML. Is it possible to add a battery with 1% increments as of now?
Sent from my Nexus S using XDA App
nbeebe24 said:
Thank you very much for that! I edited the images I want to use, I waes just trying to add the respective values into the XML. Is it possible to add a battery with 1% increments as of now?
Sent from my Nexus S using XDA App
Click to expand...
Click to collapse
I have no idea all I know is on the EVO you had to edit the services.jar for that and it is beyond my capabilities. Sorry.
zone23 said:
I have no idea all I know is on the EVO you had to edit the services.jar for that and it is beyond my capabilities. Sorry.
Click to expand...
Click to collapse
I'll pay money if someone can link me to the decompiled battery_stat_sys and battery_charge_sys XML's
Sent from my Nexus S using XDA App
Hey nbeebe24, check out my post over here: http://forum.xda-developers.com/showthread.php?t=1063657
This should help you decompile/recompile framework-res.apk for your mod. I look forward to seeing your results
nbeebe24 said:
I'll pay money if someone can link me to the decompiled battery_stat_sys and battery_charge_sys XML's
Sent from my Nexus S using XDA App
Click to expand...
Click to collapse
you tryed this tool
Code:
http://ragotnicolas.free.fr/Android/ax10mk.rar
http://ragotnicolas.free.fr/Android/ax10mk.rar
http://forum.xda-developers.com/showthread.php?t=928864

[Q] Is it possible to edit Honeycomb XML?

I've been searching everywhere and asking questions but can't seem to get answers. I am a noob to theming but I'd like to know if its possible to edit a few XML files in the Res/drawable folder? If so, please tell me how.
Sent from my Xoom using XDA Premium App
You must decompile the APK in order to "read" the xml. See decompiler post.

Question regarding PhoneWindowManager.java

first of all, i am not sure whether should i ask this question so sorry if i posted at the wrong place.
I wish to modify my Search Button, as you can see here
and found out that i have to edit platform/frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
but I have no idea where to find the file, can anyone of you tell me where to locate the file?
need to decompile apk using apktool? If yes, then which file? etc etc
reference : [HOWTO] Remap hardware button to ICS recent apps
Mr-YC said:
first of all, i am not sure whether should i ask this question so sorry if i posted at the wrong place.
I wish to modify my Search Button, as you can see here
and found out that i have to edit platform/frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
but I have no idea where to find the file, can anyone of you tell me where to locate the file?
need to decompile apk using apktool? If yes, then which file? etc etc
reference : [HOWTO] Remap hardware button to ICS recent apps
Click to expand...
Click to collapse
The path looks like a source code file, and not an APK you can decompile to edit...
'platform/frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java'
You'll need to download the Android source and edit the file. More information about downloading and compiling source can be found here:http://forum.xda-developers.com/showthread.php?t=1505006
The reference page has a link to the MOD that you can download and flash via recovery.
DennisBold said:
The path looks like a source code file, and not an APK you can decompile to edit...
'platform/frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java'
You'll need to download the Android source and edit the file. More information about downloading and compiling source can be found here:http://forum.xda-developers.com/showthread.php?t=1505006
The reference page has a link to the MOD that you can download and flash via recovery.
Click to expand...
Click to collapse
Or he could use Virtuous Ten Studio to get the java source code from an apk or jar file (for this mod, the file should be android.policy.jar)
Jonny said:
Or he could use Virtuous Ten Studio to get the java source code from an apk or jar file (for this mod, the file should be android.policy.jar)
Click to expand...
Click to collapse
you way seems to be easier so i tried yours first. hope i did everything right.
i tried using Virtuous Ten Studio to edit system/framework/android.policy.jar by creating New Jar-Project and everything succeed
i got a long list of .smali but i don't know how to edit =(
mainly because i was expecting .java file... lol
really need some help here...
EDIT: found PhoneWindowManager.class but couldn't find APP_SWITCH in it
PhoneWindowsManager.class is indeed the correct file, however it is different for each ROM
reference page works ONLY for CM9.
from what i understand, android.policy.jar of ViperS is much more complicated as it combined with its own unique Venom Tweaks
so, thank you for your help and hope m0narx or shinzlon notice this thread and give me some hint as i realized "tweak_longpress_search" is missing from the file, and i am clueless as how to call and create new function in that file.
if anyone know please tell me the answer as well =)
Mr-YC said:
you way seems to be easier so i tried yours first. hope i did everything right.
i tried using Virtuous Ten Studio to edit system/framework/android.policy.jar by creating New Jar-Project and everything succeed
i got a long list of .smali but i don't know how to edit =(
mainly because i was expecting .java file... lol
really need some help here...
EDIT: found PhoneWindowManager.class but couldn't find APP_SWITCH in it
Click to expand...
Click to collapse
if you want the java source code I think you need to hunt around in the options, im pretty sure I saw something about getting java source code out of an apk/jar file
yes, PhoneWindowsManager.class is a product from ticking "Generate Java Code" and have to go through JavaSrc\com\android\internal\policy\impl to get to that
so i am pretty sure PhoneWindowsManager.class in ViperS rom is the same as PhoneWindowsManager.java in CM9 as it contain information on longpress behavior and etc
for example:
Code:
/*
static void access$300(PhoneWindowManager phonewindowmanager, long l)
{
int i = android.provider.Settings.System.getInt(phonewindowmanager.mContext.getContentResolver(), "tweaks_longpress_home", 0);
if (i != 0)
{
if (i != 1)
{
if (i == 2)
phonewindowmanager.startCustom(l);
} else
{
phonewindowmanager.takeScreenshotS(l);
}
} else
{
phonewindowmanager.startRecentTasks(l);
}
return;
}
*/
is the matched with the following attachment
but this segment of code is comment-ed out for don't know what reason, really need help from the dev team

smali help

hello everyone
i searched a lot but couldnt find anything so postiong here
i was trying to add some featues to home.apk and i got some errors while recompiling
so i tried decompile and recompile without editing anything...i didnt even open the decompiled home apk folder LOL
but i am getting lots of smali errors only in styles.xml
i think that apktool removes some templates from styles.xml i dont know what it means i just got it from my search
so can someone help me in fixing that error....
@serajr
 @SpaceCaker
 @marcussmith2626
 @iSiddharth
Either wrong framework loaded or using wrong apktool version
And please stop abusing the mention system - I won't reply to anymore mentions
marcussmith2626 said:
Either wrong framework loaded or using wrong apktool version
And please stop abusing the mention system - I won't reply to anymore mentions
Click to expand...
Click to collapse
Ah sorry
But what do u mean by WRONG apktool version??
abhishekr700 said:
Ah sorry
But what do u mean by WRONG apktool version??
Click to expand...
Click to collapse
use
gingerbread/ics/jb 1.5.2
https://code.google.com/p/android-apktool/downloads/list
jb/kitkat/lolipop apktool rc3
https://bitbucket.org/iBotPeaches/apktool/downloads
use correct framework-res
plus any other framework eg tw-framework
Use Advanced APK Tools for decompiling the APK files and you can also use the Attached Dex Editor to edit classes.dex files.....
Advanced APK tools is specially made for Xperia devicex. (use your "framework-res.apk" to install firmware in Advanced APK Tools)
(Drag and drop classes.dex in "Quick-Baksmali.cmd" to decompile and drag and drop the output folder is "Quick-Smali.cmd" to recompile.
Advanced APK Tools : http://forum.xda-developers.com/showthread.php?t=2639400

Categories

Resources