本文介绍了请帮助减少 Xamarin.Android apk 大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发 Android 应用,但尺寸似乎很大!我启用了专业防护,链接全部启用,但似乎没有太大作用.我有四个小图像,但每个图像的大小约为 5-10kb.只有当我使用共享运行时运行时它较小,但这不适用于发布.这些是我唯一的构建警告:

I have been working on an Android app but size seems very large! I have pro guard enabled, link all enabled but dosent seem to do much. I have four small images but their size is around 5-10kb each.The only time it is smaller is when I run with shared runtime but that's not Ok for publishing. These are my only build warnings:

Warning     can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [classes.jar:META-INF/MANIFEST.MF])

Warning     can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [internal_impl-22.2.1.jar:META-INF/MANIFEST.MF])

这些警告是否与问题有关?

Do these warnings have anything to do with issue?

推荐答案

这个 apk 大小似乎没有什么问题.

Nothing seems amiss with that apk size.

仅支持一种链接 SDK 和用户程序集的 ARCH 类型的Hello World"Xamarin.Android 应用大约为 4MB(对于 ARCH 类型 armeabi-v7a).

A "Hello World" Xamarin.Android app supporting just one ARCH type that is linking SDK and User assemblies would be around 4MB (for ARCH type armeabi-v7a).

每个额外包含的 ARCH 类型都将添加另一组 libmonodroid.so 和 libmonosgen-2.0.so...请记住,在 Android 上运行的 Mono 是一个 NDK 应用程序,因此必须包含 每个 拱形类型.APK 大小不是物理设备上实际安装的应用程序的大小,因为 Android 操作系统会在安装过程中从 APK 中剥离实际需要的本机库.

Each additional included ARCH type is going to add another set of libmonodroid.so and libmonosgen-2.0.so... Remember Mono running on Android is an NDK application and thus must include native code for each ARCH type. The APK size is NOT the size of the actual installed application on the physical device as the Android OS will strip the actual needed native libraries from the APK during the install.

因此,在您包含三种架构类型的情况下,您只为 Mono/MonoDroid 运行时查看 9+MB:

So in your case of including three arch types, you are looking at 9+MB just for the Mono/MonoDroid runtime:

./armeabi:
   144912  libmonodroid.so
  2835260  libmonosgen-2.0.so

./armeabi-v7a:
   144916  libmonodroid.so
  2790212  libmonosgen-2.0.so

./x86:
   128436  libmonodroid.so
  3449836  libmonosgen-2.0.so

了解 Xamarin.Android 中 APK 的组成部分

这篇关于请帮助减少 Xamarin.Android apk 大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 23:04