Is there an equivalent for Rails.env in Android or some other way to determine in runtime if the current code is running in a development, testing or production environment?
Asked
Active
Viewed 40 times
0
fernandohur
- 7,014
- 11
- 48
- 86
1 Answers
0
Using Eclipse or Ant, your project contains a BuildConfig class, code-generated into your application's package (i.e., the same package that has your R, the one from the package attribute of the <manifest> element). This contains a public static data member, DEBUG, which will be true or false based upon whether you did a debug or production build. There is no concept here of "testing".
The new Gradle-based build system, currently under development, will give you much more flexibility here.
CommonsWare
- 986,068
- 189
- 2,389
- 2,491
-
BuildConfig is very unreliable, check https://code.google.com/p/android/issues/detail?id=27940 and http://www.digipom.com/be-careful-with-buildconfig-debug/ and http://stackoverflow.com/questions/9855834/when-does-adt-set-buildconfig-debug-to-false – fernandohur Aug 05 '13 at 14:53