Repository navigation
fix: align posthog-android to core's major with a Gradle constraint - #974
Merged
turnipdabeets merged 1 commit intoNov 12, 2026
Merged
Conversation
posthog-android 3.x calls core APIs that 7.0 removes, so an app that pins core 7.x next to posthog-android 3.x crashes with NoSuchMethodError when it builds PostHogAndroidConfig. Publish a constraint from core to posthog-android at the matching major so Gradle upgrades posthog-android instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
posthog-android Compliance ReportDate: 2026-11-12T18:29:08.684748+00:00 ✅ All Tests Passed!232/232 tests passed Capture_V1 Tests✅ 105/105 tests passed View Details
Capture_Ai_V1 Tests✅ 110/110 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
turnipdabeets
marked this pull request as ready for review
November 12, 2026 19:08
PR overviewNo security issues were found in this pull request. Reviews
|
There was a problem hiding this comment.
Approved.
The disclosed dependency and publishing changes enter risky territory, covered by the current-head independent review reported in the trusted context. No unresolved substantive concerns or other refusal grounds were found.
- Author wrote 0% of the modified lines and has 39 merged PRs in these paths (familiarity MODERATE).
- PostHog Review (Standard) reviewed the current head: no findings.
Gate mechanics and policy version
| Gate | Result | |
|---|---|---|
| prerequisites | ✓ | all clear |
| deny-list | ✓ | no deny categories matched |
| size | ✓ | 10L, 1F substantive, 11L/2F incl. docs/generated/snapshots — within ceiling |
| tier | ✓ | T1-agent / T1b-small (11L, 2F, two-areas, fix) |
| stamphog 2.8.0 | .stamphog/policy.yml @ 5b113b7 · reviewed head 5b113b7 |
This was referenced Nov 12, 2026
fix(android): fail the build when posthog-android would be raised to 4.x
PostHog/posthog-flutter#728
Closed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
Stacked on #871.
An app can end up with core
posthog7.x next toposthog-android3.x, for example by declaringcom.posthog:posthogdirectly or getting it from another library. posthog-android 3.x then calls core APIs that 7.0 removes, and the app crashes withNoSuchMethodErroras soon as it buildsPostHogAndroidConfig, because the oldPostHogConfigconstructor is gone. We can't fix that in 3.x code that's already published, and it fails in the app's own config call before any SDK code we control runs.This PR publishes a Gradle dependency constraint from core to
com.posthog:posthog-androidat the matching major (<androidVersion major>.0.0, so4.0.0at release). The constraint doesn't add posthog-android to anyone's dependencies. It only applies when posthog-android is already there, and then Gradle upgrades it to 4.x instead of shipping the broken combination. Server SDK users aren't affected.The other direction is already safe:
posthog-android4.0 pulls core 7, and Gradle picks the highest version, so core can't stay on 6.x unless an app forces it.posthog-android-surveys-compose0.5.0 (built against posthog-android 3.75.1) links cleanly against 4.0, so it needs no constraint for now.Limits:
dependencyManagemententry, which Maven doesn't apply to consumers.strictlygets a build-time resolution error instead of a runtime crash.💚 How did you test it?
Bytecode linkage check. A scratch script checked every
com/posthogmember reference in the published AARs against jars built from this branch:posthog-android3.76.2 against core 7: 33 missing references, includingPostHogConfig.<init>. This confirms the crash.posthog-android-surveys-compose0.5.0 against android 4 + core 7: 0 missing.End-to-end resolution. I published core
7.0.0and posthog-android4.0.0from this branch to a scratch Maven repo, then resolvedreleaseRuntimeClasspathin a throwaway AGP 8.9.1 library:posthog-android:3.76.2+posthog:7.0.0posthog-android:3.76.2 -> 4.0.0(dependencyInsight: "By constraint: posthog-android must match the major of the core posthog artifact")posthog-android:4.0.0+posthog-android-surveys-compose:0.5.0posthog-android:3.76.2only (control)Checked the generated
module.jsonand POM for the constraint.:posthog-server's runtime classpath doesn't include posthog-android, the lockfiles don't change, andspotlessCheckpasses.I didn't add a committed test. A check that the build file declares the constraint would only restate the build file, and the useful check (resolving against published artifacts) needs a separate consumer build.
📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file. Added a bullet to the shared.changeset/android-v4-major.md.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Claude Code (Opus 5.5) did the investigation and the change. We started by checking the claim that mixing 4.0 and 3.x packages crashes the app. The
.apidumps leave out@PostHogInternalmembers that are still public in bytecode, so the binary-compatibility verdicts come from the bytecode linkage check, not the API diff. I considered and dropped a matching constraint from posthog-android to surveys-compose, since today's surveys-compose release is binary-compatible with 4.0. A runtime version guard was also ruled out, because the crash happens in the app's own config construction before SDK code runs.🤖 Generated with Claude Code