java - VS中的 Release模式和 Debug模式

标签 java c# android visual-studio xamarin

我目前正在使用Android应用程序,但是对VS有点了解。

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

在研究期间,我遇到了123这两个问题,谈论了两者之间的区别。


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


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


  
  那些调试符号是什么?
  obj / Debug或obj / Release中的“ 81”文件夹是什么?
  我还注意到,有时,当从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   



  
  发布应用程序时,这些警告是否真的是我需要担心的事情?它们会导致其他错误吗?
  


我已经尝试过:


删除这些文件。
清洗解决方案和整个项目。

最佳答案

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

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

实际例子

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

但是,由您决定要为特定配置设置什么设置。
默认情况下,Release配置将优化代码以使其运行更快。
同样,默认情况下,Debug配置的Debugging信息对Debug来说是完整的,而pdb仅对Release而言。
但是,您将无法仅在带有pdb的Release配置中附加调试器。

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

对您的问题:

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

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

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

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

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

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上传到Playstore之前,我建议您阅读以下Android指南
Publish your app guide

关于java - VS中的 Release模式和 Debug模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54508031/

相关文章:

c# - 如何从接口(interface)返回派生程度更高的类型?

c# - 每个 Visual Studio 选项卡中的小挂锁符号是什么?

android - 适用于 Android 应用的自定义词典(非键盘)

android - 使用 showAsAction ="ifRoom"未在 ActionBar 中显示操作项

java - 在 ArrayList Java 中搜索特定对象

c# - 如何检查列是否可以转换为 double ? (DataTable.Column.DataType)

java - Long 类型的方法参数缺少 URI 模板变量 'usuarioEntidade'

java - TextView 和 ImageView 脱离 LinearLayout

java - 什么时候必须关闭数据库?

java - 从 Android 中的自定义对象动态更新 textView