Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[HOW TO] Use Apktool

OP v6ser

26th January 2012, 09:28 PM   |  #1  
v6ser's Avatar
OP Senior Member
Flag Rome now, Brasilia before
Thanks Meter: 152
 
118 posts
Join Date:Joined: Jan 2012
Donate to Me
So, here i'm again porting a tutorial based on DSM_'s Tut

What do you need:
JRE (Java Runtime Environment)
MOD EDIT: Download Removed.

Install:

Windows:
MOD EDIT: Download Removed.
MOD EDIT: Download Removed.
Unpack both pakages you will get three files, copy those files to your Windows directory i.e. C:\WINDOWS

Decoding files:
Open Command. Run>cmd
Type-
Quote
apktool d file.apk [directory]
Example - apktool d D:\nfsshift.apk D:\nfsshift
Done!


FrameworkFiles

Apktool needs the framework files to decode and build apks.

Standard framework is embedded into apktool, so you don't need to do anything for most apk files. But some manufacturers, for example Samsung, add their own framework files and use them in system apps. To use apktool against such apps, you must pull framework from a device and install/register it to apktool.

For Example, you want to decode TouchWizLauncher.apk from Android v2.2 of Galaxy 5. If you try to do that, you will get an error message:


You need to install framework in apktool Type-

apktool if [framework location]


I have the got the framework-res.apk & twframework-res.apk by extracting the ROM. You can also copy it from your phone. But take care you must copy framework.apk from that ROM in which you got the Application file.




Then try again


Now is working.


How to build decoded files:
Just type

apktool b [directory in which you have decoded the files]
Example - apktool b D:\nfsshift
Done!



You will find the apk file inside the decoded directory, like I found it in - D:\nfsshift\dist\nfsshift.apk

Now you need to sign your APK file.


How to Sign APK files:


When publishing an application or a custom rom you need to sign the .apk or .zip files with a certificate using a private key. The Android system uses the certificate to identify the author of an application and establish trust relationship between applications. The classic way of doing this was to use keytool then sign it with jarsigner. In this tutorial i’ll explain an alternative method which is relatively easy to use for most people using a tool called SignApk.jar.

First download the SignAPK toolMOD EDIT: Download Removed.
Extract them to a directory you will remember. I have put them in C:\SignApk

Now just open cmd and type -
Quote

cd C:\SignApk
java -jar signapk.jar certificate.pem key.pk8 your-app.apk your-app-signed.apk
Example - java -jar signapk.jar certificate.pem key.pk8 D:\nfsshift\dist\nfsshift.apk D:\nfsshift\dist\nfsshift-signed.apk



Your APK is signed and can be installed.
Last edited by The-Captain; 23rd February 2013 at 04:45 AM.
The Following 72 Users Say Thank You to v6ser For This Useful Post: [ View ]
25th February 2012, 03:58 PM   |  #2  
Theonewithideas's Avatar
Senior Member
Flag Jagodina
Thanks Meter: 55
 
300 posts
Join Date:Joined: Oct 2011
More
Why I get errors when trying to decode some apk's from Xperia S? Apk's are okay, working on phone. Decompiling works on other apps.

I've registered framework-res.apk from my phone.
26th February 2012, 02:47 AM   |  #3  
leith51's Avatar
Senior Member
Thanks Meter: 778
 
3,676 posts
Join Date:Joined: Feb 2009
Donate to Me
More
Quote:
Originally Posted by Theonewithideas

Why I get errors when trying to decode some apk's from Xperia S? Apk's are okay, working on phone. Decompiling works on other apps.

I've registered framework-res.apk from my phone.

You may require another one like the dhd has com.htc.resources.apk

sent from my dhd
The Following User Says Thank You to leith51 For This Useful Post: [ View ]
7th March 2012, 05:44 PM   |  #4  
Aarush's Avatar
Senior Member
Flag New Delhi
Thanks Meter: 700
 
1,499 posts
Join Date:Joined: Jan 2012
More
i decompiled defaulthemes.apk from my Xperia neo v
now when i compile it again .. do i need to sign it? its a system apk!

and i am not able to build decode files( it means compiling right?).. please help!
Last edited by Aarush; 7th March 2012 at 06:14 PM.
13th March 2012, 11:43 PM   |  #5  
Theonewithideas's Avatar
Senior Member
Flag Jagodina
Thanks Meter: 55
 
300 posts
Join Date:Joined: Oct 2011
More
Quote:
Originally Posted by Aarush

i decompiled defaulthemes.apk from my Xperia neo v
now when i compile it again .. do i need to sign it? its a system apk!

and i am not able to build decode files( it means compiling right?).. please help!

I think you need to replace it manually first time. But make a backup, just in case.

---------- Post added at 10:43 PM ---------- Previous post was at 10:18 PM ----------

I've decoded the system app (from Xperia S) (after registering the 2 framework files)
Edited the code inside. Compiled. Signed. But when I want to install it it gives me error. The usual icon doesn't show up either.

Is the error caused by changing something in code? I've only edited some TextSize values.
14th March 2012, 08:44 PM   |  #6  
Aarush's Avatar
Senior Member
Flag New Delhi
Thanks Meter: 700
 
1,499 posts
Join Date:Joined: Jan 2012
More
Quote:
Originally Posted by Theonewithideas

I think you need to replace it manually first time. But make a backup, just in case.

---------- Post added at 10:43 PM ---------- Previous post was at 10:18 PM ----------

I've decoded the system app (from Xperia S) (after registering the 2 framework files)
Edited the code inside. Compiled. Signed. But when I want to install it it gives me error. The usual icon doesn't show up either.

Is the error caused by changing something in code? I've only edited some TextSize values.

Can be with codes
Are u signing it.? Dont sign it if its a system apk

Sent from my Xperia neo V using SwiftKey!
19th March 2012, 05:40 AM   |  #7  
cowsquad's Avatar
Senior Member
Flag Portland, Oregon
Thanks Meter: 267
 
1,116 posts
Join Date:Joined: Aug 2009
Donate to Me
More
Great tutorial

Sent from my Droid using Tapatalk
28th March 2012, 09:28 PM   |  #8  
Senior Member
Flag Stockholm
Thanks Meter: 299
 
248 posts
Join Date:Joined: Nov 2011
Donate to Me
More
Why shouldn't you sign a system apk? I see people stating this everywhere, never any reason as to why though.

Basically, if I mess with a system apk I should just build it and then it's ready to adb push to /system/app/?
30th March 2012, 12:18 PM   |  #9  
nba1341's Avatar
Senior Member
Flag San Bernardino, California
Thanks Meter: 166
 
1,092 posts
Join Date:Joined: Feb 2011
More
very helpful thanks
17th April 2012, 11:48 AM   |  #10  
goldiecalypso's Avatar
Senior Member
Island of Ogygia
Thanks Meter: 53
 
185 posts
Join Date:Joined: Jan 2012
Question I've done all your steps but...
@hyztname

hi, how are you

I've done what you said in post #1 step by step, everything's ok with no error but when I push my new edited "SystemUI.apk" to the device, it doesn't work. I have the same issue when I use APKMultiTool

what do you think?

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes