Skip to content

Instantly share code, notes, and snippets.

@JakeSteam
Created March 18, 2019 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JakeSteam/6052f0f3a7ac523649c4f05d1d1cb1fb to your computer and use it in GitHub Desktop.
Save JakeSteam/6052f0f3a7ac523649c4f05d1d1cb1fb to your computer and use it in GitHub Desktop.
Automatically adding build time to your Android app
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 17
targetSdkVersion 28
versionCode 8
versionName "1.1.0"
buildConfigField "java.util.Date", "BUILD_TIME", "new java.util.Date(" + System.currentTimeMillis() + "L)"
}
}
private fun setupVersionInfo() {
findPreference(getString(R.string.pref_version)).title = "V${BuildConfig.VERSION_NAME}"
findPreference(getString(R.string.pref_version)).summary = String.format(
getString(R.string.version_summary),
BuildConfig.VERSION_CODE,
SimpleDateFormat("dd MMM yyy", Locale.US).format(BuildConfig.BUILD_TIME)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment