Skip to content
Merged
Prev Previous commit
Next Next commit
Fix versionCode truncation on Android API 28+
Change versionCode from Int to Long in UpdateCheckParams to prevent silent
truncation of large version codes when using packageInfo.longVersionCode.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
  • Loading branch information
runningcode and claude committed Sep 29, 2025
commit b238c29efe92e348520cc77ab0e26d0440f39c90
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal class DistributionHttpClient(private val options: SentryOptions) {
val mainBinaryIdentifier: String,
val appId: String,
val platform: String = "android",
val versionCode: Int,
val versionCode: Long,
val versionName: String,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ public class DistributionIntegration(context: Context) : Integration, IDistribut
val versionName = packageInfo.versionName ?: "unknown"
val versionCode =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
packageInfo.longVersionCode.toInt()
packageInfo.longVersionCode
} else {
@Suppress("DEPRECATION") packageInfo.versionCode
@Suppress("DEPRECATION") packageInfo.versionCode.toLong()
}
val appId = context.applicationInfo.packageName

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DistributionHttpClientTest {
mainBinaryIdentifier = "com.emergetools.hackernews",
appId = "com.emergetools.hackernews",
versionName = "1.0.0",
versionCode = 5,
versionCode = 5L,
)

val response = httpClient.checkForUpdates(params)
Expand Down
Loading