Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道是否有人知道如何在调试模式和发布模式之间切换代码?例如,在 C# 中,有 #debug 来区分调试代码。#debug 中的代码仅在调试模式下执行。
感谢您提前提供任何帮助。
据此( 2012年 3 月修订):
Build 添加了一项功能,允许您仅在调试模式下运行某些代码。构建现在生成一个名为的类,BuildConfig其中包含一个DEBUG根据您的构建类型自动设置的常量。 您可以检查BuildConfig.DEBUG代码中的 ( ) 常量以运行仅调试功能。
BuildConfig
DEBUG
BuildConfig.DEBUG