So, Android Developer - Android Studio User Guide - Tips and Recipes Gradle - Simplified application development actually documents what to add in order to have a release time stamp available for your application:
android { ... buildTypes { release { // These values are defined only for the release build, which // is typically used for full builds and continuous builds. buildConfigField("String", "BUILD_TIME", "\"${minutesSinceEpoch}\"") resValue("string", "build_time", "${minutesSinceEpoch}") ... } debug { // Use static values for incremental builds to ensure that // resource files and BuildConfig aren't rebuilt with each run. // If they were dynamic, they would prevent certain benefits of // Instant Run as well as Gradle UP-TO-DATE checks. buildConfigField("String", "BUILD_TIME", "\"0\"") resValue("string", "build_time", "0") } } } ...
In the application code, you can access the properties as follows:
... Log.i(TAG, BuildConfig.BUILD_TIME); Log.i(TAG, getString(R.string.build_time));
I have included this here, since all other solutions, apparently, were before the official example.
Morrison Chang Dec 02 '18 at 6:45 2018-12-02 06:45
source share