Skip to content

Commit 97ec26e

Browse files
fix: Change to time based version code to resolve pre-release Manager unable to update to latest stable release
1 parent 924c8dc commit 97ec26e

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

app/build.gradle.kts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,17 @@ android {
155155

156156
val versionStr = if (version == "unspecified") "1.0.0" else version.toString()
157157
versionName = versionStr
158-
versionCode = with(versionStr.toVersion()) {
159-
major * 10_000_000 +
160-
minor * 10_000 +
161-
patch * 100 +
162-
(preRelease?.substringAfterLast('.')?.toInt() ?: 0)
163-
}
158+
159+
// VersionCode derived from current time (1-minute intervals) + offset.
160+
val nowMillis = System.currentTimeMillis()
161+
val timestampVersionCode = (nowMillis / (60 * 1000)).toInt()
162+
// Offset of the prior v1.1.1 version code to ensure the code is always newer for old installs.
163+
// If a new app is used this offset should be changed to zero.
164+
// 1 minute rounding and this offset still gives ~4,000 years of valid version codes
165+
// and still fall into Play store max version code range.
166+
val versionCodeOffset = 10010100
167+
versionCode = timestampVersionCode + versionCodeOffset
168+
164169
vectorDrawables.useSupportLibrary = true
165170
}
166171

0 commit comments

Comments
 (0)