Created
March 18, 2019 22:06
-
-
Save JakeSteam/6052f0f3a7ac523649c4f05d1d1cb1fb to your computer and use it in GitHub Desktop.
Automatically adding build time to your Android app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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