简体   繁体   English

如何知道我的Android应用程序是在发布版还是调试模式下构建的?

[英]How can I know if my android app was built in release or debug mode?

In my app I use Google Analytics and Admob as you know (or not) I can use both of them in a mode that doesn't influences the data on the server (debug mode). 在我的应用中,我使用谷歌分析和Admob你知道(或不)我可以在不影响服务器数据的模式下使用它们(调试模式)。

I tired of changing each time I release my app this things and I can also mistake and release it with debug mode and then I won't get data... 我厌倦了每次我发布我的应用程序时更改这些东西,我也可能会错误并使用调试模式释放它然后我将无法获取数据...

How can I know programmatically if I run in debug\\release mode? 如果我在调试\\发布模式下运行,我怎么能以编程方式知道?

In C# I can check this using: 在C#中我可以使用以下方法检查:

#If DEBUG then

How can I do this in Android? 我怎样才能在Android中执行此操作?

You can try by checking the flag 您可以尝试检查标志

BuildConfig.DEBUG

And this is how I use normally. 这就是我正常使用的方式。

if (BuildConfig.DEBUG) {
  Log.e(Constants.TAG, "onCreate called");
}

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

相关问题 如何调试仅在发布模式下崩溃的 Android 应用 - How do I debug an Android app that crashes only in Release Mode 当我的 Xamarin 应用程序仅在发布模式下中断时,如何调试它? - How can I debug my Xamarin app when it only breaks in release mode? 如何在发布模式下调试Android应用程序? - How to debug android app on release mode? 为什么我的(android)phonegap应用程序可以在调试模式下工作,而不能在发布模式下工作? - Why my (android) phonegap app works on debug mode but not on release mode? 我可以将我的Android应用程序构建为调试,但使用发布密钥库进行签名 - Can I build my Android app as debug but sign with release keystore 如何使用 Android Studio 在发布模式下调试 Android 应用程序 - How to debug the Android App in release mode using Android studio 如何在Android Studio中以调试模式运行AndroidTestCases? - How can I run my AndroidTestCases in debug mode in Android Studio? Android - 用于调试和发布模式的应用程序图标 - Android - app icon for debug and release mode Android应用程式在侦错模式下运作良好,但在发布模式下当机 - Android app working fine in debug mode but crashing in release mode 在调试模式下运行的同一Android应用程序在发布模式下崩溃 - Same Android app who runs on Debug mode, crashes on release mode
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM