如何使用 Xamarin.Android 从最终 APK 文件中删除未使用的语言? [英] How do I remove unused languages from the final APK file with Xamarin.Android?
问题描述
我已经在我的项目中添加了一些 Android 支持库,现在我基本上面临与这个问题中描述的相同的问题:Android Studio 将字符串从支持库导出到 APK
I've added some of the Android support libraries to my project and now I'm basically facing the same problem as described in this question: Android Studio exports strings from support library to APK
由于我无法在 Xamarin 中使用 Gradle 设置,因此我无法使用 StackOverflow 答案中描述的解决方案.
Since I can't use Gradle settings with Xamarin, I can't use the solution described in the StackOverflow answer.
有人知道如何在最终的 APK 文件中只保留特定的本地化吗?
Does anyone have an idea, how I can keep only specific localization in my final APK file?
推荐答案
所以我终于设法以一种理智的方式做到了这一点
So I've finally managed to do this in a sane way
- 从https://ibotpeaches.github.io/Apktool/下载
Apktool
/a> - 使用 Xamarin 创建最终的 .apk 并使用
apktool d MyApp.apk
反编译它 - 进入
Apktool
创建的MyApp
目录并查找res
目录 - 删除所有以您不需要的语言标识符结尾的
values
目录,例如,如果您的应用仅支持德语,请删除values-fr
、values-es
等...,但不是values-de
.不要删除非语言目录,例如values-v11
! - 使用
apktool b MyApp
重新编译您的应用 - 重新编译的应用程序包现在位于
MyApp/dist/MyApp.apk
.获取此文件并使用 signtool 对其进行签名,然后对其进行 zipalign. - 将 apk 上传到 Google Play
- Download
Apktool
from https://ibotpeaches.github.io/Apktool/ - Create your final .apk with Xamarin and decompile it with
apktool d MyApp.apk
- Go into the
MyApp
directory thatApktool
has created and look for theres
directory - Remove all
values
directories that end with a language identifier that you don't need, e.g if your app only supports the German language, removevalues-fr
,values-es
, etc..., but notvalues-de
. Don't remove non-language directories, e.gvalues-v11
! - Recompile your app with
apktool b MyApp
- The recompiled app package is now in
MyApp/dist/MyApp.apk
. Take this file and sign it with the signtool, then zipalign it. - Upload the apk to Google Play
我确信这个过程可以自动化,一旦我有一个脚本,我就会更新这个答案.
I'm sure this process can be automated, I'll update this answer as soon as I have a script for that.
这篇关于如何使用 Xamarin.Android 从最终 APK 文件中删除未使用的语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!