简体   繁体   English

请帮助减少Xamarin.Android的apk大小

[英]Please help reducing Xamarin.Android apk size

I have been working on an Android app but size seems very large! 我一直在研究Android应用,但尺寸看起来非常大! 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. 我有四张小图片,但每张图片大小约为5-10kb。 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? 这些警告与问题有关吗?

The apk is about 14MB, including armeabi, amreabi-v7a, x86. apk大约14MB,包括armeabi,amreabi-v7a,x86。 Link setting is: 'Sdk and User Assemblies' 链接设置为:'Sdk和用户装配'

Nothing seems amiss with that apk size. 这个apk大小没什么好看的。

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). 支持SDK和用户程序集的一种ARCH类型的“Hello World”Xamarin.Android应用程序大约为4MB(对于ARCH类型armeabi-v7a)。

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. 每个额外包含的ARCH类型将添加另一组libmonodroid.so和libmonosgen-2.0.so ...记住在Android上运行的Mono是一个NDK应用程序,因此必须包含每种 ARCH类型的本机代码。 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. APK大小不是物理设备上实际安装的应用程序的大小,因为Android OS将在安装期间从APK中剥离实际所需的本机库。

So in your case of including three arch types, you are looking at 9+MB just for the Mono/MonoDroid runtime: 因此,在包含三种arch类型的情况下,您只需为Mono / MonoDroid运行时查看9 + MB:

./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

Understanding the Constituent Pieces of APKs in Xamarin.Android 在Xamarin.Android中理解APK的组成部分

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM