如何使用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
- 使用Xamarin创建最终的.apk,然后使用
apktool d MyApp.apk
对其进行反编译
- 进入
Apktool
创建的MyApp
目录,然后查找res
目录 - 删除所有以不需要的语言标识符结尾的
values
目录,例如,如果您的应用仅支持德语,则删除values-fr
,values-es
等,但不删除. 请勿删除非语言目录,例如 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屋!