繁体   English   中英

VS中的发布模式和调试模式

[英]Release Mode and Debug Mode in VS

我目前正在开发一个Android应用程序,我和VS搞砸了一下。

我想知道,两种模式之间的真正区别是什么? 我做了一些研究,但我并没有完全了解每一个的真正差异和优点,以及何时使用特定模式。

在我的研究,我碰到这些问题123 ,谈到两者之间的差异。

  1. 为什么调试模式比发布模式运行得慢?
  2. 将应用程序发布到Google Play时,我应该使用哪种模式?为什么?
  3. 我可以创建自己的模式吗?

我的应用程序似乎在调试模式下构建良好,但在发布模式下,我收到很多关于“未找到调试符号文件”的警告。

  1. 那些调试符号是什么?
  2. obj / Debug或obj / Release中的“81”文件夹是什么?
  3. 我还注意到,有时,当从Debug切换到Release时,找不到一些Resource.Id,我需要为布局重新创建axml文件并清理sln。 我该怎样预防呢?

据我所知,调试模式使用一些文件,释放模式不需要运行,我假设丢失的文件是那些“调试符号”? 也许这是Xamarin或VS的问题? 这些是我得到的警告:

Warning     Directory obj\Release\81\android/assets contains Xamarin.Android.Support.v7.AppCompat.dll but no debug symbols file was found.          0   
Warning     Directory obj\Release\81\android/assets contains Java.Interop.dll but no debug symbols file was found.          0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.Android.Arch.Core.Common.dll but no debug symbols file was found.          0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.Android.Arch.Lifecycle.Common.dll but no debug symbols file was found.         0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.Android.Arch.Lifecycle.Runtime.dll but no debug symbols file was found.            0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.Android.Support.Animated.Vector.Drawable.dll but no debug symbols file was found.          0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.Android.Support.Annotations.dll but no debug symbols file was found.           0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.Android.Support.Compat.dll but no debug symbols file was found.            0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.Android.Support.Core.UI.dll but no debug symbols file was found.           0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.Android.Support.Core.Utils.dll but no debug symbols file was found.            0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.Android.Support.Design.dll but no debug symbols file was found.            0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.Android.Support.Fragment.dll but no debug symbols file was found.          0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.Android.Support.Media.Compat.dll but no debug symbols file was found.          0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.Android.Support.Transition.dll but no debug symbols file was found.            0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.Android.Support.v4.dll but no debug symbols file was found.            0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.Android.Support.v7.RecyclerView.dll but no debug symbols file was found.           0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.Android.Support.Vector.Drawable.dll but no debug symbols file was found.           0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.GooglePlayServices.Base.dll but no debug symbols file was found.           0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.GooglePlayServices.Basement.dll but no debug symbols file was found.           0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.GooglePlayServices.Maps.dll but no debug symbols file was found.           0   
Warning     Directory obj\Release\81\android/assets contains Xamarin.GooglePlayServices.Tasks.dll but no debug symbols file was found.          0   
  1. 在发布应用程序时,这些警告是否真的需要我担心? 它们会导致任何进一步的错误吗?

我已经尝试过:

  1. 删除这些文件。

  2. 清理解决方案和整个项目。

我试着给你一个简短的概述,并添加一些参考。 你不会来阅读一些书籍或网页。

配置只是用于构建的特定设置集的标签。

实际的例子

调试:为开发人员开发具有许多功能的应用程序,这些功能可以提高开发速度,如完全记录和调试启用DevelopmentRelease:对于测试团队。 禁用调试,启用优化,完整日志记录,使用广泛的崩溃报告,使用测试基础架构(例如测试服务器)您还可以使用不同的清单,以便您拥有不同的软件包名称并可以并行安装应用程序。 发布:将部署到Playstore选择性能和稳定性禁用调试,减少日志记录,优化代码,使用生产基础架构(例如服务器)

但是,由您为特定配置设置的设置取决于您。 默认情况下,Release配置将优化代码以更快地运行。 此外,默认情况下,Debug配置的调试信息已完全用于Debug,而pdb仅用于Release。 但是,您将无法仅使用pdb将调试器附加到Release配置中。

pdb文件用于将生成的代码映射到源代码。 PDB文件:每个开发人员必须知道的内容

对你的问题:

1.为什么调试模式比发布模式运行得慢?

因为完成了一些优化(优化代码标志)=>更改代码以更快地运行。 你可能不会有这种感觉。 当不需要调试时,还有其他性能优势,例如,不需要断点解析等等。

2.在向Google Play发布应用程序时,我应该使用哪种模式?为什么?

始终采用发布模式,因为此版本通常运行得更快,更稳定。 您可能已在Debug配置中设置了使用共享运行时:这将单声道运行时部署为设备的单独应用程序,以便在调试模式下部署更快=>仅需要部署代码中的更改。 但是,当您将调试版本上载到Playstore时,App将无法运行,因为缺少共享运行时App。 如果使用Proguard进行代码混淆,这通常也是一种仅在发布模式下启用的功能。 Proguard主页

如果您有自动构建管道,则通常不需要在本地计算机上进行Release构建,因为这是由构建服务器完成的。

3.我可以创建自己的模式吗? 是的,正如我已经提到的。 按下配置旁边的箭头,然后打开配置管理器。 在配置管理器中,按下拉列表活动配置并选择新建。 您还可以复制现有配置。 =>总是在* .csproj文件中查看配置包含的内容。 Visual Studio并不总是能够复制所有配置条目。

4.那些调试符号是什么?

您可以忽略这些警告,您不需要代码的pdb文件,而不是您的。

5. obj / Debug或obj / Release中的“81”文件夹是什么?

我不知道你为什么关心obj文件夹,但81包含版本8.1的android内容,在构建期间使用

6.我还注意到,有时,当从Debug切换到Release时,找不到一些Resource.Id,我需要为布局重新创建axml文件并清理sln。 我该怎样预防呢?

我还在较旧的visual studio版本中观察到了这种行为。 目前我使用VS 15.9.4与Xamarin 4.3.12.77,这通常很好。 源的问题可能是在构建过程中生成了资源ID。 当你切换到发布配置时,这些符号也必须生成以便发布,并且可能会使VS混乱。

7.在发布应用程序时,这些警告是否真的需要我担心? 它们会导致任何进一步的错误吗?

别担心! 缺少Pdb文件不会导致他们没有捆绑到apk的任何麻烦。

在您将apk上传到Play商店之前,我建议您阅读以下Android指南发布您的应用指南

暂无
暂无

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

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