【问题标题】:Release Mode and Debug Mode in VSVS 中的发布模式和调试模式
【发布时间】:2019-02-03 22:01:32
【问题描述】:

我目前正在开发一个 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. 清理解决方案和整个项目。

【问题讨论】:

  • @SushiHangover 你能提供更多细节吗?什么是调试符号以及为什么 VS 将其标记为警告?

标签: java c# android visual-studio xamarin


【解决方案1】:

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

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

实例

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

但是,为特定配置设置什么设置取决于您。 默认情况下,发布配置将优化代码以更快地运行。 此外,默认情况下,Debug 配置具有完整的 Debug 调试信息和仅用于 Release 的 pdb。 但是您将无法在仅使用 pdb 的发布配置中附加调试器。

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

对于您的问题:

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

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

2。将应用程序发布到 Google Play 时,我应该使用哪种模式以及为什么?

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

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

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

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

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

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

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

6.我还注意到,有时,从调试切换到发布时,找不到一些 Resource.Id,我需要为布局重新创建 axml 文件并清理 sln。我该如何预防?

我还在旧版 Visual Studio 中观察到了这种行为。 目前我将 VS 15.9.4 与 Xamarin 4.3.12.77 一起使用,这通常可以正常工作。 源的问题可能是在构建过程中生成了 Resource id。 当您切换到发布配置时,还必须为发布生成这些符号,并且可能 VS 会搞砸。

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

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

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

【讨论】:

  • 优秀的答案!在第 4 个答案中,你是什么意思不是我的?什么是共享运行时 App?
  • @DanielReyhanian“不是你的代码”你没有编写的代码(来自 google 或 nuget 包的 Android 代码),Xamarin 应用程序在单运行时中运行,这个运行时在发布模式下打包到 apk 中.在 Debug 中,它被部署为一个单独的应用程序。查看详情:docs.microsoft.com/en-us/xamarin/android/deploy-test/…
猜你喜欢
  • 1970-01-01
  • 2017-03-27
  • 2015-07-15
  • 2011-09-21
  • 2011-10-30
  • 2021-02-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多