Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,738,368 Members 51,524 Now Online
XDA Developers Android and Mobile Development Forum

[HOW TO] Use Apktool

Tip us?
 
v6ser
Old
(Last edited by The-Captain; 23rd February 2013 at 03:45 AM.)
#1  
v6ser's Avatar
Senior Member - OP
Thanks Meter 152
Posts: 118
Join Date: Jan 2012
Location: Rome now, Brasilia before

 
DONATE TO ME
Thumbs up [HOW TO] Use Apktool

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.
If I helped you hit thanks



CM9, AOKP and S-Voice for MDPI/LDPI porter

checkout my work at MADTEAM
The Following 72 Users Say Thank You to v6ser For This Useful Post: [ Click to Expand ]
 
Theonewithideas
Old
#2  
Theonewithideas's Avatar
Senior Member
Thanks Meter 54
Posts: 293
Join Date: Oct 2011
Location: Jagodina
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.
 
leith51
Old
#3  
leith51's Avatar
Senior Member
Thanks Meter 778
Posts: 3,676
Join Date: Feb 2009

 
DONATE TO ME
Quote:
Originally Posted by Theonewithideas View Post
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: [ Click to Expand ]
 
Aarush
Old
(Last edited by Aarush; 7th March 2012 at 05:14 PM.)
#4  
Aarush's Avatar
Senior Member
Thanks Meter 698
Posts: 1,485
Join Date: Jan 2012
Location: New Delhi
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!

| Xperia neo V | Nexus 5 (current) |
| My theme | My second theme | Transparent statusbar (ICS) | CRT Off (GB) |



 
Theonewithideas
Old
#5  
Theonewithideas's Avatar
Senior Member
Thanks Meter 54
Posts: 293
Join Date: Oct 2011
Location: Jagodina
Quote:
Originally Posted by Aarush View Post
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.
 
Aarush
Old
#6  
Aarush's Avatar
Senior Member
Thanks Meter 698
Posts: 1,485
Join Date: Jan 2012
Location: New Delhi
Quote:
Originally Posted by Theonewithideas View Post
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!

| Xperia neo V | Nexus 5 (current) |
| My theme | My second theme | Transparent statusbar (ICS) | CRT Off (GB) |



 
cowsquad
Old
#7  
cowsquad's Avatar
Senior Member
Thanks Meter 265
Posts: 1,098
Join Date: Aug 2009
Location: Portland, Oregon

 
DONATE TO ME
Great tutorial

Sent from my Droid using Tapatalk
 
fritzhy
Old
#8  
Senior Member
Thanks Meter 298
Posts: 246
Join Date: Nov 2011
Location: Stockholm

 
DONATE TO ME
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/?
 
nba1341
Old
#9  
nba1341's Avatar
Senior Member
Thanks Meter 164
Posts: 1,079
Join Date: Feb 2011
Location: San Bernardino, California
very helpful thanks
Nexus 7 (2013) 16GB: 4.3 rooted
T-Mobile Galaxy S4 16GB: CM 10.2
T-Mobile Note 3 32GB: Stock rooted
 
goldiecalypso
Old
#10  
goldiecalypso's Avatar
Senior Member
Thanks Meter 53
Posts: 186
Join Date: Jan 2012
Location: Island of Ogygia
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?



Sony Xperia C - Official 4.2.2
Star B92M - Official 4.0.4 [ROOTED]
MSI Windpad Enjoy10 - Gingerbread 2.3.1, Official 0224 [ROOTED]
HTC HD2 - TyphooN CyanogenMod 7
T-Mobile HTC HD2 - WM6.5
Samsung i900 Omnia - OCK's WM6.5 Premium
Eten glofiish X600 - WM6.0


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes