From 5d5281810d839fdf83c9ab21f19a578b46b7233b Mon Sep 17 00:00:00 2001 From: Anna Garcia Date: Thu, 12 Nov 2026 16:02:59 -0500 Subject: [PATCH] fix(android): make the posthog-android 4.x range strict A plain range lets Gradle raise posthog-android past 4.x when something else in the app asks for a newer major, and the plugin, compiled against 4.x, would crash at runtime instead of failing the build. Co-Authored-By: Claude Opus 5.5 --- .changeset/v6-major-release.md | 1 + posthog_flutter/android/build.gradle | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.changeset/v6-major-release.md b/.changeset/v6-major-release.md index 3ca595a9..86b9a39c 100644 --- a/.changeset/v6-major-release.md +++ b/.changeset/v6-major-release.md @@ -7,6 +7,7 @@ - **Breaking:** remove CocoaPods support on iOS and macOS — install through Swift Package Manager, which needs the Flutter SDK 3.41 or later and doesn't support add-to-app modules yet - **Breaking:** adopt `posthog-ios` 4.x, which requires Xcode 26 - **Breaking:** adopt `posthog-android` 4.x +- Fail the Android build instead of crashing at runtime when another dependency would raise `posthog-android` past 4.x - **Breaking:** remove `PostHogConfig.apiKey` and the `com.posthog.posthog.API_KEY` manifest and Info.plist key — use `projectToken` and `com.posthog.posthog.PROJECT_TOKEN` - **Breaking:** remove `Posthog().enable()` and `Posthog().disable()`, and rename `enable()` and `disable()` to `optIn()` and `optOut()` on `PosthogFlutterPlatformInterface`, `PosthogFlutterIO` and `PosthogFlutterWeb` — use `optIn()` and `optOut()` - **Breaking:** add `options` to `capture`, `screen`, `identify`, `setPersonProperties`, `alias`, `group` and `captureException`, and `defaultValue` to `isFeatureEnabled()`, add `captureAi()`, `setAppLanguage()`, `registerOptions()` and `unregisterOptions()`, and remove `getFeatureFlagPayload()` on `PosthogFlutterPlatformInterface` — update subclasses and test fakes diff --git a/posthog_flutter/android/build.gradle b/posthog_flutter/android/build.gradle index fd123302..6f2cf2de 100644 --- a/posthog_flutter/android/build.gradle +++ b/posthog_flutter/android/build.gradle @@ -67,7 +67,11 @@ android { testImplementation 'org.robolectric:robolectric:4.14.1' testImplementation 'junit:junit:4.13.2' testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.10.1' - implementation 'com.posthog:posthog-android:[4.0.0,5.0.0)' + // strictly: Gradle otherwise raises a plain range when the app or another library asks for a + // newer posthog-android, and this plugin, compiled against 4.x, then crashes at runtime. + implementation('com.posthog:posthog-android') { + version { strictly '[4.0.0,5.0.0)' } + } } testOptions {