在Android上区分发展模式和释放模式环境设置 [英] Distinguishing development mode and release mode environment settings on Android
问题描述
我要建一个Android应用程序,并想保持一些环境变量,我可以根据我是否在开发模式或释放模式调整。例如,我需要调用Web服务和URL将两种模式略有不同。我想这种外部化和其他设置,以便我可以根据我的目标部署很容易地改变它们。
I'm building an Android application and would like to maintain a few environment variables that I can tweak depending on whether I'm in development mode or release mode. For example, I need to invoke a web service and the URL will be slightly different in either mode. I'd like to externalize this and other settings so I can change them easily based on my target deployment.
有没有在SDK中的任何的最佳做法或任何协助这方面的需要?
Are there any best practices or anything in the SDK to assist with this need?
推荐答案
根据这个计算器<一个href="http://stackoverflow.com/questions/3029819/android-automatically-choose-debug-release-maps-api-key/3828864"标题=Android的:自动选择调试/发布地图API密钥?>帖子,在SDK工具版本17(我们是在19截至记者发稿)增加了一个 BuildConfig.DEBUG
不变,建立一个开发建设的时候是真的。
According to this stackoverflow post, in SDK Tools version 17 (we're on 19 as of this writing) adds a BuildConfig.DEBUG
constant that is true when building a dev build.
这篇关于在Android上区分发展模式和释放模式环境设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!