Xamarin应用程序很大,为什么而且可以更小 [英] xamarin apps are large why and can they be smaller

查看:84
本文介绍了Xamarin应用程序很大,为什么而且可以更小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Xamarin和Android Studio创建了一个Hello World应用程序.当我输入 App Manager 时,使用Xamarin构建的应用程序大小为47 Mb,而使用Android Studio的应用程序大小为12 Mb.我知道跨平台必须更大,但是为什么这么大呢?没有任何导出设置可以缩小它吗?

I created an Hello World app using Xamarin and Android Studio. When I enter the App Manager, the application built with Xamarin has a size of 47 Mb whereas the size of the application with Android Studio has a size of 12 Mb. I know that the cross-platform must be larger, but why is it this big? Isn't there any export setting that can make it smaller?

推荐答案

它之所以大,是因为它最多包含一个包含应用程序,库,Mono运行时等的程序包,例如BCL库(基类库)..在下面,您可以找到基本发行版软件包的软件包大小

It is large because it most contain a package that includes the application, the libraries, the Mono runtime and so on such as the BCL libraries (Base class libraries). Below, you can find how the size of the packages for a a basic release package

对于调试,有些不同.首先,在Android设备上调试时,需要复制2个larges程序包(共享运行时和平台).第一个包含BCL和mono运行时,另一个包含您的应用将定位的特定droid API级别.

For debug, it's a bit different. At first, when debugging on an Android device, it's required to copy 2 larges packages (Shared Runtime & Platform). The first contains the BCL and the mono runtime and the other one contains the specific droid API level that your app would be targeting.

为了在调试时减小应用程序大小,可以使用快速程序集部署选项.此选项使您可以在测试设备上直接安装所需的软件包.这样做可以大大减小应用程序包的大小.为此,请在Xamarin Studio中找到选项".然后,您将找到Build部分,然后单击Android Build.最后,单击使用共享的Mono运行时"和快速程序集部署"复选框.保存所做的更改并在连接设备的情况下构建您的应用程序,您应该会很好:)

In order to reduce the app size while debugging, you can use fast assembly deployment option. This option enables you to install directly the packages you require on your testing device. Doing so, the app package size is greatly reduced. To do so, find the Options inside of Xamarin Studio. Then, you're going to find the Build section and click on Android Build. Finally, click on both Use shared Mono runtime and the Fast assembly deployment checkboxes. Save your changes and build your app with your device connected and you should be good to go :)

更新1

在评论中讨论了一段时间之后,我发现最好在此处包含所有相关信息,而不是强迫读者在评论部分中仔细阅读并了解有关他/她所学内容的更多信息来到这里寻找.因此,我被问到在发布模式下可以减小应用程序大小的方式.在发布模式下,您将必须使用@ kent.green中有关链接的帖子.这篇文章的快速概述:链接使您可以通过通过使用静态分析并删除应用程序未使用的程序集来将其大小从14.0 Mb到4.4 Mb.对于希望在iOS上使用类似功能的用户,请查看此帖子.

After talking about it for a while in the comments, I found that it would be best to have all the relevant information in here instead of forcing the reader to go downs in the commentary section and find out more about what he/she came here to find. So I was ask about about the way one would be able to reduce the app size in Release mode. In the release mode, you're going to have to use the post of the @kent.green concerning Linking. A quick overview of the post: Linking enables you to moves from an app with a size of 14.0 Mb to 4.4 Mb by using static analysis and removing assemblies that aren't use by the app in any way possible. For people looking for something similar for iOS, take a look at this post.

此外,OP还担心他/她的应用程序的调试模式.OP希望通过启用快速程序集部署来了解是否会丢失诸如资源监视或崩溃报告之类的功能.我的回答是,从技术角度来看,事实是仍然存在相同的功能.而不是使用大小为X的应用程序包,而是通过使用您的测试设备来减小程序包的大小,并在其中放置不必要的"内容以使程序包更小.我认为这两个共享库都不会受到此影响.

Also, the OP was concerned about the debug mode of his/her app. The OP wanted to know if by enabling fast assemblies deployment if one would lose functionalities such as resources monitoring or crash reports. I responded by saying that, from on a technical point of view, the fact remains that the same functionality is there. Instead of having an app package of size X, the size of the package is being reduced by using the your testing device and put "unnecessary" stuff there to make the package smaller. I do not think that both Shared libraries are being affected by this.

这篇关于Xamarin应用程序很大,为什么而且可以更小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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