Android - 如何从 apk 中提取针对一种特定区域/语言的资源

Pas*_*cal 2 resources android internationalization apk

编辑:

请参阅下面我的回答:apktool可以完成这项工作。


编辑:

汉诺·宾德评论:

显然,-c 选项仅在打包资源时有效,而不是在提取资源时有效。


我尝试使用“aapt”工具从 apk 中提取 fr 字符串。

我能够获得这样的所有资源:

.\android-sdks\build-tools\23.0.2\aapt.exe d --values 资源 my.apk > 资源。所有.txt

我只想获取给定区域设置的资源,例如 fr(法语)。关于这一点,aapt 文档指出:

   -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
Run Code Online (Sandbox Code Playgroud)

所以我尝试了

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

但输出仍然包含所有配置的字符串 (/locales)。

问题:

我该怎么办?

笔记:

我很确定 apk 确实包含 fr 数据,因为我使用以下方法获取了 apk 配置:

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

fr 在配置列表中。(另外,我在资源中看到一些fr字符串。全部.txt)

Pas*_*cal 5

实现此目的的一种方法是使用apktool

$ apktool d theApkYouWantToExtractResourcesOf.apk
Run Code Online (Sandbox Code Playgroud)

这将生成一个 ./theApkYouWantToExtractResourcesOf/ 文件夹,其中包含所有资源,包括

./theApkYouWantToExtractResourcesOf/res/values-<language>/
Run Code Online (Sandbox Code Playgroud)

我对法国琴弦很感兴趣,并在这里找到了它们:

./theApkYouWantToExtractResourcesOf/res/values-fr/strings.xml
Run Code Online (Sandbox Code Playgroud)

任务完成!