如何使用Xamarin.Android从最终的APK文件中删除未使用的语言? [英] How do I remove unused languages from the final APK file with Xamarin.Android?

查看:185
本文介绍了如何使用Xamarin.Android从最终的APK文件中删除未使用的语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在项目中添加了一些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

  1. https://ibotpeaches.github.io/Apktool/下载Apktool
  2. 使用Xamarin创建最终的.apk,然后使用apktool d MyApp.apk
  3. 对其进行反编译
  4. 进入Apktool创建的MyApp目录,然后查找res目录
  5. 删除所有以不需要的语言标识符结尾的values目录,例如,如果您的应用仅支持德语,则删除values-frvalues-es等,但不删除. 请勿删除非语言目录,例如values-v11
  6. 使用apktool b MyApp
  7. 重新编译您的应用
  8. 重新编译的应用程序包现在位于MyApp/dist/MyApp.apk中.取出该文件并使用signtool对其进行签名,然后将其zipalign.
  9. 将APK上传到Google Play
  1. Download Apktool from https://ibotpeaches.github.io/Apktool/
  2. Create your final .apk with Xamarin and decompile it with apktool d MyApp.apk
  3. Go into the MyApp directory that Apktool has created and look for the res directory
  4. 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, remove values-fr, values-es, etc..., but not values-de. Don't remove non-language directories, e.g values-v11!
  5. Recompile your app with apktool b MyApp
  6. The recompiled app package is now in MyApp/dist/MyApp.apk. Take this file and sign it with the signtool, then zipalign it.
  7. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆