Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 8
    BuildConfig.VERSION_NAME is already a string, no need to call toString() on it.
    – Makotosan
    Commented Apr 4, 2016 at 19:52
  • Habit. Fair enough
    – Mullazman
    Commented Apr 6, 2016 at 9:12
  • There are cases when calling this in your project may get different result from what you would expect. For example if you use an android submodule in your project and you call it from the code of the submodule it will reference to build config of the submodule which may have different version. Or if you call it from the code of your project you may reference by mistake to build config of your submodule and get the same result. Just be careful and double check that you reference to a proper package of the build config.
    – MikeL
    Commented Oct 5, 2016 at 19:55
  • Try using this guide: medium.com/@manas/…
    – CrandellWS
    Commented Aug 19, 2018 at 2:30
  • difference is BuilConfig is provided by Gradle whereas getting it at runtime is by PackageManager (OS) Commented Jan 24, 2020 at 17:58