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

查看:18
本文介绍了如何使用 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/a>
  2. 使用 Xamarin 创建最终的 .apk 并使用 apktool d MyApp.apk
  3. 反编译它
  4. 进入 Apktool 创建的 MyApp 目录并查找 res 目录
  5. 删除所有以您不需要的语言标识符结尾的 values 目录,例如,如果您的应用仅支持德语,请删除 values-frvalues-es 等...,但不是 values-de.不要删除非语言目录,例如 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天全站免登陆