Skip to content

chore: upgrade to Kotlin 2.1.10, AGP 8.9.1, compileSdk 36, minSdk 23#460

Open
marandaneto wants to merge 11 commits intomainfrom
chore/upgrade-kotlin-2-agp-compilesdk-36
Open

chore: upgrade to Kotlin 2.1.10, AGP 8.9.1, compileSdk 36, minSdk 23#460
marandaneto wants to merge 11 commits intomainfrom
chore/upgrade-kotlin-2-agp-compilesdk-36

Conversation

@marandaneto
Copy link
Member

@marandaneto marandaneto commented Mar 13, 2026

💡 Motivation and Context

Upgrade the Android SDK build toolchain to modern versions:

  • Kotlin: 1.8.22 → 2.1.10 (with languageVersion/apiVersion = 2.0 for consumer compatibility)
  • AGP: 8.2.2 → 8.9.1
  • Gradle: 8.7 → 8.12
  • compileSdk: 33 → 36 (Android 16)
  • minSdk: 21 → 23

Also upgrades dependencies: OkHttp 4.12.0, Robolectric 4.14.1, Dokka 1.9.20, Kover 0.9.0, binary-compatibility-validator 0.16.3, build-config plugin 5.5.1, and others.

Inspiration: PostHog/posthog-flutter#245

Key code changes required by the upgrades

  • Switched Compose compiler from kotlinCompilerExtensionVersion to kotlin("plugin.compose") plugin (Kotlin 2.0+ approach)
  • Fixed Kotlin 2.x stricter enforcement of duplicate default parameter values across inherited interfaces — removed defaults from PostHogInterface.identify() and PostHogInterface.debug() (the implementing classes still provide defaults)
  • Added @Suppress("DEPRECATION") for Gson JsonParser() usage in PostHogSerializer
  • Removed dead code branches for API < 23 checks (now always true with minSdk 23)
  • Removed unnecessary API version checks in replay integrations (PostHogReplayIntegration, PostHogLogCatIntegration)
  • Updated network connectivity tests to mock the API 23+ activeNetwork/getNetworkCapabilities path
  • Added lint baseline entries for new lint checks in AGP 8.9.1
  • Deduplicated shared build versions into gradle.properties as single source of truth (consumed by buildSrc, PosthogBuildConfig, and the Gradle plugin)
  • Updated sdk_compliance_adapter Dockerfile and build to use shared versions

CI fix

  • Fixed flaky PostHogTest.capture with appendFeatureFlags uses local evaluation test by increasing MockWebServer takeRequest timeout from 100ms to 2s (too short for slower CI runners)

💚 How did you test it?

  • make compile
  • make test (all JVM + Android unit tests) ✅
  • make checkFormat

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 13, 2026

posthog-android Compliance Report

Date: 2026-03-18 16:51:11 UTC
Duration: 147094ms

⚠️ Some Tests Failed

28/29 tests passed, 1 failed


Capture Tests

⚠️ 28/29 tests passed, 1 failed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 2312ms
Format Validation.Event Has Uuid 2029ms
Format Validation.Event Has Lib Properties 2026ms
Format Validation.Distinct Id Is String 2024ms
Format Validation.Token Is Present 2022ms
Format Validation.Custom Properties Preserved 2022ms
Format Validation.Event Has Timestamp 2021ms
Retry Behavior.Retries On 503 7023ms
Retry Behavior.Does Not Retry On 400 4024ms
Retry Behavior.Does Not Retry On 401 4023ms
Retry Behavior.Respects Retry After Header 7026ms
Retry Behavior.Implements Backoff 17022ms
Retry Behavior.Retries On 500 7023ms
Retry Behavior.Retries On 502 7027ms
Retry Behavior.Retries On 504 7021ms
Retry Behavior.Max Retries Respected 17035ms
Deduplication.Generates Unique Uuids 2041ms
Deduplication.Preserves Uuid On Retry 7025ms
Deduplication.Preserves Uuid And Timestamp On Retry 12033ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 7031ms
Deduplication.No Duplicate Events In Batch 2033ms
Deduplication.Different Events Have Different Uuids 2027ms
Compression.Sends Gzip When Enabled 2022ms
Batch Format.Uses Proper Batch Structure 2018ms
Batch Format.Flush With No Events Sends Nothing 2014ms
Batch Format.Multiple Events Batched Together 2027ms
Error Handling.Does Not Retry On 403 4021ms
Error Handling.Does Not Retry On 413 4021ms
Error Handling.Retries On 408 7021ms

Failures

error_handling.does_not_retry_on_413

Expected 1 requests, got 2

The 'capture with appendFeatureFlags uses local evaluation' test was
failing on CI because the 100ms timeout for collecting subsequent
MockWebServer requests was too short for slower CI machines. Increased
to 2 seconds to allow enough time for all requests to arrive.
@marandaneto marandaneto force-pushed the chore/upgrade-kotlin-2-agp-compilesdk-36 branch from b156f2c to 142b36c Compare March 18, 2026 16:35
@marandaneto marandaneto marked this pull request as ready for review March 18, 2026 16:36
@marandaneto marandaneto requested a review from a team as a code owner March 18, 2026 16:36
Comment on lines 27 to -69
@@ -66,7 +66,7 @@ public sealed interface PostHogInterface {
/**
* Enables or disables the debug mode
*/
public fun debug(enable: Boolean = true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it's not backward compatible


<issue
id="NewApi"
message="Call requires API level 24 (current min is 23): `android.graphics.drawable.GradientDrawable#getColors`"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On SDK 23, will this degrade gracefully?

val ANIMAL_SNIFFER = "1.7.1"
val ANIMAL_SNIFFER_SDK_VERSION = "5.0.1_r2" // API 21
val ANIMAL_SNIFFER = "1.7.2"
val ANIMAL_SNIFFER_SDK_VERSION = "6.0_r3" // API 23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean we can finally get Integer.hashCode? 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants