amplitude / amplitude/Amplitude-Flutter
amplitude_flutter + amplitude_session_replay crash on Android startup: shared analytics-core resolves to 1.29.x → NoSuchFieldError RemoteConfigClient$Key.ANALYTICS_SDK
- Lingua principale
- Dart
- Stelle
- 133
- Fork
- 108
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
## Summary
Using the two official Flutter plugins **`amplitude_flutter`** and **`amplitude_session_replay`** together in one Android app causes a hard crash on launch. They share the transitive native module `com.amplitude:analytics-core`, and their requirements are mutually incompatible: Gradle resolves `analytics-core` to **1.29.x**, where `RemoteConfigClient.Key` was changed from an `enum class` to a `sealed class` (removing the static `ANALYTICS_SDK` field), while both plugins' compiled bytecode still reads that field.
## Crash
```
java.lang.NoSuchFieldError: No field ANALYTICS_SDK of type
Lcom/amplitude/core/remoteconfig/RemoteConfigClient$Key;
in class Lcom/amplitude/core/remoteconfig/RemoteConfigClient$Key; or its superclasses
```
Surfaced via a Google Play pre-launch report; reproduces on any device at app startup.
## Environment
- `amplitude_flutter`: **4.5.0** (also **4.6.0**, the latest — identical native pin)
- `amplitude_session_replay`: **0.1.0-beta.1**
- Flutter (Android Kotlin DSL), AGP 8.11.1, Kotlin 2.2.20, compileSdk 36, minSdk 26
## Root cause
1. `com.amplitude:analytics-core` **1.29.0** (PR #409, "align RemoteConfigClient key model with iOS/Web") converted `RemoteConfigClient.Key` from `enum class Key(val value: String)` — which had the static field `ANALYTICS_SDK` — to a `sealed class Key`, **removing that static field**.
2. `amplitude_flutter` (4.5.0 **and** latest 4.6.0) pins `com.amplitude:analytics-android:1.27.+` (→ 1.27.0, enum), with an in-source comment declining 1.28+ (NoSuchMethodError, #283).
3. `amplitude_session_replay` 0.1.0-beta.1 allows `com.amplitude:session-replay-android:[0.26.0,0.27.0)`, which resolves to **0.26.4** — and 0.26.4 requires `com.amplitude:analytics-core:[1.29.0,2.0.0)` (the sealed model).
4. Because both plugins share `analytics-core` and session-replay's requirement is open-ended, Gradle's highest-version-wins picks `analytics-core` **1.29.x**. Both plugins' `getstatic RemoteConfigClient$Key.ANALYTICS_SDK` references then throw `NoSuchFieldError` at startup.
## Dependency resolution evidence
`./gradlew :app:dependencies` (release runtime classpath), unmodified project:
```
+--- com.amplitude:analytics-android:1.27.+ -> 1.27.0
+--- com.amplitude:session-replay-android:[0.26.0,0.27.0) -> 0.26.4
+--- com.amplitude:analytics-core:[1.29.0,2.0.0) -> 1.29.1 <-- sealed class, no ANALYTICS_SDK field
```
## Impact
Any app combining the two **current, official** Flutter plugins crashes on Android launch. There is no published combination that works out of the box — even the latest `amplitude_flutter` 4.6.0 still pins `analytics-android:1.27.+`.
## Requested fix
Publish an `amplitude_flutter` release whose `analytics-android` dependency is compatible with the `analytics-core` **1.29.x** (sealed-class) line that `session-replay-android` ≥ 0.26.4 now requires — i.e. resolve #283 so the pin can move to ≥ 1.29.0 — and document a compatible version matrix between `amplitude_flutter` and `amplitude_session_replay`.
## Current workaround
Force the whole native Amplitude stack back to the enum-era core in `android/app/build.gradle.kts`:
```kotlin
configurations.all {
resolutionStrategy {
force("com.amplitude:analytics-core:1.27.0")
force("com.amplitude:analytics-android:1.27.0")
force("com.amplitude:session-replay-android:0.26.3") // last enum-compiled patch
}
}
```
(A single `reject("[1.29.0,)")` constraint does **not** work — Gradle refuses to auto-downgrade `session-replay-android` from 0.26.4 and fails resolution instead.)
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.