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

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

问题描述

我使用 Xamarin 和 Android Studio 创建了一个 Hello World 应用.当我进入应用程序管理器时,使用 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个大包(Shared Runtime & Platform).第一个包含 BCL 和单声道运行时,另一个包含您的应用程序将针对的特定 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.最后,单击 Use shared Mono runtime 和 Fast assembly deployment 复选框.保存您的更改并在连接您的设备的情况下构建您的应用程序,您应该很高兴:)

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天全站免登陆