Pascal
Pascal

Reputation: 16631

Android - How to extract resources from apk FOR ONE SPECIFIC LOCALE/LANGUAGE

EDIT:

See my answer below: apktool does the job.


EDIT:

Comment from Hanno Binder:

"Apparently, the -c option is only valid when p[ackaging] resources, not for extracting them."


I try to extract fr strings from an apk using the 'aapt' tool.

I am able to get all resources like this:

.\android-sdks\build-tools\23.0.2\aapt.exe d --values resources my.apk > resources.all.txt

I would like to only get resources for a given locale, for instance, fr (French). About that, aapt documentation states:

   -c  specify which configurations to include.  The default is all
       configurations.  The value of the parameter should be a comma
       separated list of configuration values.  Locales should be specified
       as either a language or language-region pair.  Some examples:
            en
            port,en
            port,land,en_US

So I tried

.\android-sdks\build-tools\23.0.2\aapt.exe d -c fr --values resources my.apk > resources.fr.txt

but the outpout still contains strings for all configurations (/locales).

Question:

How am I supposed to do?

Note:

I am pretty sure the apk does contains fr data since I fetched apk configurations using:

.\android-sdks\build-tools\23.0.2\aapt.exe d --values configurations my.apk > configurations.txt

and fr is in the list of configurations. (Also, I see some fr strings in resources.all.txt)

Upvotes: 2

Views: 9203

Answers (1)

Pascal
Pascal

Reputation: 16631

A way to achieve this is to use apktool.

$ apktool d theApkYouWantToExtractResourcesOf.apk

and this will generate a ./theApkYouWantToExtractResourcesOf/ folder contains all resources including

./theApkYouWantToExtractResourcesOf/res/values-<language>/

I was interested in french strings and found them here:

./theApkYouWantToExtractResourcesOf/res/values-fr/strings.xml

Job done!

Upvotes: 6

Related Questions