代码之家  ›  专栏  ›  技术社区  ›  Daniel Reyhanian

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

  •  1
  • Daniel Reyhanian  · 技术社区  · 7 年前

    在我的研究中,我遇到了这些问题 1 2 和 3 ,谈论两者之间的差异。

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

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

    1. 那些调试符号是什么?
    2. 我还注意到,有时候,当从调试切换到发布时,找不到一些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 回复  |  直到 7 年前
        1
  •  4
  •   eugstman    7 年前

    我试着给你一个简单的概述,并添加一些参考资料。 你不会过来看一些书或网页。

    这些配置只是用于生成的一组特定设置的标签。

    实例

    开发发布:针对测试团队。禁用调试、启用优化、完整日志记录、使用大量崩溃报告、使用测试基础架构(例如测试服务器) 您还可以使用不同的清单,以便使用不同的软件包名称并并行安装应用程序。 版本:将部署到playstore,选择性能和稳定性禁用调试、减少日志记录、优化代码、使用生产基础设施(如服务器)

    默认情况下,版本配置将优化代码以更快地运行。 此外,默认情况下,调试配置中包含调试信息完整(用于调试),pdb仅用于发布。 但是,您将无法在仅使用pdb的版本配置中附加调试器。

    pdb文件用于将生成的代码映射到源代码。 PDB Files: What Every Developer Must Know

    关于你的问题:

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

    你可能不会有这种感觉。当不需要调试时,还有其他性能优势,例如不需要断点解析,等等。

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

    始终采用发布模式,因为此版本通常运行更快、更稳定。 您可能在调试配置中设置了使用共享运行时: 这会将mono运行时作为单独的应用程序部署到设备上,以便在调试模式下的部署更快=>只需部署代码中的更改。 但是,当您将调试版本上载到playstore时,该应用程序将不会运行,因为缺少共享运行时应用程序。 如果您使用Proguard进行代码混淆,这通常也是仅在发布模式下启用的功能。 Proguard Home Page

    如果您有一个自动构建管道,您通常不必在本地计算机上发布构建,因为这是由构建服务器完成的。

    3.我可以创建自己的模式吗? 是的,我已经说过了。按下配置旁边的箭头并打开Configuration manager。 您还可以复制已存在的配置=&燃气轮机;始终在*.csproj文件中查看配置包含的内容。 Visual Studio并非总是能够复制所有配置条目。

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

    您可以忽略这些警告,因为您不需要pdb文件来编写非您的代码。

    我不知道你为什么关心obj文件夹,但是81包含了android版本8.1的东西,在构建过程中使用

    我在较旧的VisualStudio版本中也观察到了这种行为。 目前我在Xamarin 4.3.12.77中使用VS15.9.4,这通常很好。 源代码的问题可能是在构建过程中生成了资源id。 当您切换到发布配置时,这些符号也必须为发布生成,可能VS会把事情搞砸。

    7.在发布应用程序时,这些警告真的是我需要担心的吗?它们会引起更多的错误吗?

    别担心这个! 缺少Pdb文件不会给您带来任何麻烦,因为它们没有绑定到apk。

    在将apk上传到playstore之前,我建议您阅读以下Android指南 Publish your app guide