ab1956ea1261
fix: derive versionCode from VERSION to prevent ApkIdentityMismatch (v2.9.34)
- time
- 2026-08-02 01:38 UTC · 2 months ago
- machine
- koh2
- parent
- b5bc115f86c6
↓ peach-android-ab1956ea.tar.gzatlas at this save
files changed1 file
app/build.gradle+11 −4app/build.gradle+11 −4
@@ -23,16 +23,23 @@2323 if (!(semanticVersion ==~ /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/)) {2424 throw new GradleException("VERSION must contain exactly one strict major.minor.patch value")2525 }26- if (semanticVersion.split("\\.").any { it.toBigInteger() > Integer.MAX_VALUE }) {27- throw new GradleException("VERSION contains a semantic-version component outside Gradle's supported range")26+ def versionParts = semanticVersion.split("\\.")27+ def vMajor = versionParts[0].toInteger()28+ def vMinor = versionParts[1].toInteger()29+ def vPatch = versionParts[2].toInteger()30+ if (vMajor > 99 || vMinor > 99 || vPatch > 999) {31+ throw new GradleException("VERSION components exceed versionCode encoding range (major/minor <= 99, patch <= 999)")2832 }33+ // Derive a strictly-monotonic versionCode from semver so it can never34+ // accidentally stay flat across releases (which breaks the updater's35+ // versionCode > currentVersionCode identity gate).36+ def derivedVersionCode = vMajor * 1000000 + vMinor * 10000 + vPatch * 102937 3038 defaultConfig {3139 applicationId "com.peachpasswords"3240 minSdk 263341 targetSdk 3534- // Keep the Android code in Gradle; the semantic name comes from root VERSION.35- versionCode 24016742+ versionCode derivedVersionCode3643 versionName semanticVersion3744 3845 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"