Use APKTool to Decompile, Edit, Translate and Recompile an APK

APKTool is an application (made by Brut.all) which decompiles and recompiles android APKs. If you know what you are doing, it also allows you to debug the smali code step by step. In our case it will enable us to build a language pack by translating the .xml strings inside APK files. 

This tutorial is for the Windows version of APKtool.

 The Google.Code page for APKTool is here, however, we have prepackaged everything you need and uploaded it here

The Video Tutorial is Below:

The Supplementary guide to common errors in APKTool is below:

You need to do the following preparations (the video outlines these steps anyway):

  1. Download the prepackaged APKTool zip.
  2. Extract them to a directory you will remember.
  3. Extract framework-res.apk AND apk files you want to decompile from the MIUI_Au ROM and copy them to the root directory of APKTool.

This step must be completed every time you are dealing with APKTool:

  1. Open a command window
  2. Navigate to the root directory of APKtool and type the following command:
    apktool if framework-res.apk

The output should be:

I: Framework installed to: C:\Users\Josh\apktool\framework\1.apk

This step does the actual decompiling of the APK (I will assume that the chosen APK is Settings.apk):

apktool d Settings.apk

The output should be:

I: Loading resource table…
I: Decoding resources…
I: Copying assets and libs…

After doing that, a new directory with the name of the APK you decompiled should have been created. You need to:

  1. Change into the newly created directory.
  2. Change into the /res folder
  3. Check to see if a values-xx folder exists, where xx is the two letter code of the target language to be translated into. For example, if you are aiming to translate into German, check for a values-de folder. If it does not exist (and chances are that if you are translating into a new language, that it will not exist), you need to create it. Then, copy the arrays.xml and strings.xml files from the /values folder into the folder you just created.
  4. Open these two files (in Notepad ++) and alter the strings (the text in BLACK ONLY).  Look out for things that look like  %d and %s /’  -    Don’t edit these, as they are variables.  Also, if you see &, it represents the ‘&’ sign, so feel free to change it. Finally, you MUST be sure to place a backslash ‘\’ before an apostrophe, for example Proxy\’s would be the equivalent of Proxy’s.
  5. Once you have translated and edited your arrays.xml and strings.xml files, save them, and return to the root directory of APKTool.
  6. Open a command prompt to that directory

Enter the following command to recompile your edited and translated APK (assuming that Settings.apk is the chosen APK):

apktool b Settings

The output should be:

I: Checking whether sources has changed…
I: Smaling…
I: Checking whether resources has changed…
I: Building resources…
I: Building apk file…

You may get a couple of these messages:

aapt: warning: string ‘app_killed_message’ has no default translation in C:\Users\Josh\Desktop\NF\framework-res\res; found: fr it ja
aapt: warning: string ‘global_action_reboot’ has no default translation in C:\Users\Josh\Desktop\NF\framework-res\res; found: fr it ja
aapt: warning: string ‘reboot_system’ has no default translation in C:\Users\Josh\Desktop\NF\framework-res\res; found: fr it ja
aapt: warning: string ‘toast_reboot_recommend’ has no default translation in C:\Users\Josh\Desktop\NF\framework-res

However,  it will build the apk anyway. These messages mean that some strings don’t have values. It is only an issues if the text im blue includes your translation language.

Once that is done, two directories will have been created within the decompilation directory. One will be called “dist”, and this is where it will place a built, but not signed, apk file. The other one is called “build”, and here it will place everything “loose” (the contents of the APK).

I have trouble using the APK files it spits out in the /dist folder ( they force closes if they are an application, or bootloop it a framework-res.apk; I think the reason is because Android will not accept APK files that are not signed).  Instead, copy the resources.arsc from the /build directory into the original framework-res from the rom (just overwrite the old resources.arsc one with the new one).

This tutorial is for the Windows version of APKtool.

22 Comments Posted by

22 Comments

  1. Hi Fllash,
    I’m using most of the mothod suggested to put together a version of android ics in my language. I’ve translated all of the strings.xml file (and arrays and plurals) from the values folder. After compiling it works well, all of my translated strings are there, but quite a lot of things are still in english, for exampe the day of the week displayed next to the time on the notification bar. There are several others too. These strings are translated when i select another language, e.g german, but i’ve searched all of the files within settings.apk and can’t find these particular strings. Any idea where they are? Thanks, sion

  2. Is there any video explaining this steps. I didn’t get “The output should be:

    I: Framework installed to: C:\Users\Josh\apktool\framework\1.apk”. And also in the post, it was mentioned as the video is below,but I didn’t found any video or video link. Please can anybody help.

    • What did you get as your output?

      This guide is quite old, and the process for current MIUI distributions is a tad more complex (involving multiple frameworks).

      The video was removed; I can’t remember why.

  3. AndroChef successfully decompiles obfuscated Java 6 and Java 7 .class .jar and .apk .dex files. It is simple but powerful tool that allows you to decompile Java and Dalvik bytecode (DEX, APK) into readable Java source
    http://www.neshkov.com/ac_decompiler.html

  4. Trying to decompile contacts.apk from 2.10.12 version.
    “Multiple resources: spec=0x7f020029 drawable/ecc_dial_button_bg_normal_miui, config=-hdpi”
    how to decompile ?

    • MIUI (sometime around July, to the best of my knowledge) switched their build process over to Linux, and created a modified version of apktool/aapt which only works under Linux. That’s why I had to switch to keep working on MIUI_Au.

  5. How about Korean Games??? It doesn’t have array.xml only string.xml

    • It’ll work for everything. I’ll create an updated video sometime soon outlining the process I use now (with XJ’s AutoAPKTool).

      If there is no arrays, then it just means less work for you.

  6. Hi, he’s right, depositfile links looks dead, here’s the message in french “Ce fichier n’existe pas (l’accès aux fichiers suivants est limité) ou il a été enlevé à cause de violation des droits d’auteur.”

    > File don’t exist (limited access) or have been removed because of copyright infraction !

    Can you repost please ?

    • I can’t from Uni, but visit the other link (the Google Code page) and download aapt, apktool and the bat helper file.

  7. When i type:

    apktool d myapk.apk

    it returns an error:
    input file was not found or was not readable. What does that mean? What should i do???

    Thanks in advance

    • Either your APK is corrupt (from an incomplete copy operation, perhaps?) or you aren’t pointing APKTool to the correct location.

  8. I’d like to translate 4-way reboot menu in MIUI_Au 2.4.3, but I don’t know which apk file to decompile.

  9. Say’s HTC Desire at the Top, but was wondering if this would work with HTC Evo 4G too? using ubuntu10LTS and installed apktool just wanted to know before heading in Deeper? Thank’s and very appreciative.

  10. Hi , i did all steps

    1- apktool if framework-res.apk : and the directory has been created
    C:\Users\beshoo\apktool\framework
    and it hase
    1.apk
    127.apk

    but when i type :

    C:\Users\beshoo>C:\android-sdk1hhb\apktool\apktool.exe d C:\android-sdk1hhb\apkt
    ool\net.ponury.faceniff-1.apk

    i got :

    ERROR: no dump file specified

    please advice

  11. try this

    >java apktool.jar d xxx.apk

    This step must be completed every time you are dealing with APKTool:

    Open a command window
    Navigate to the root directory of APKtool and type the following command:
    apktool if framework-res.apk ———-substitute this for what i typed above

  12. type it exactly how i typed it only substituting the xxx.apk for whatever apk you have to decompile – also make sure the apk you want to decompile is in the same folder as the apktool

Leave a Reply

Using Gravatars in the comments - get your own and be recognized!

XHTML: These are some of the tags you can use: <a href=""> <b> <blockquote> <code> <em> <i> <strike> <strong>