Android build fails under AGP 9 when analytics-kotlin is also in the dependency graph: duplicate namespace 'com.segment.analytics'
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- android, dart, flutter
- Domain
- build-system, mobile
Research direction
Inspect the plugin's Android module and AndroidManifest.xml, then reproduce the failure with flutter build apk --debug using segment_analytics and com.segment.analytics.kotlin:android. Compare the namespace and package declarations with the issue's proposed unique namespace, and verify that the Android build completes without the duplicate-namespace error.
Written by the indexing model from the issue text.
Description
The plugin's Android module declares namespace 'com.segment.analytics' — the same namespace as Segment's native Android SDK (com.segment.analytics.kotlin:android, whose AAR manifest declares package="com.segment.analytics"). AGP 9 treats duplicate namespaces as a hard manifest-merger error, so any app that has both in its dependency graph no longer builds. This happens in practice with SDKs that embed analytics-kotlin, e.g. the Customer.io SDK (customer_io → io.customer.android:datapipelines → com.segment.analytics.kotlin:android).
Steps to reproduce
- Flutter app with
segment_analytics: 1.1.12and AGP 9.x (tested with 9.1.0). - Add the native SDK to
android/app/build.gradle(or any dependency that pulls it in, e.g.customer_io):dependencies { implementation "com.segment.analytics.kotlin:android:1.24.1" } flutter build apk --debug
Result
[:segment_analytics] .../merged_manifest/debug/processDebugManifest/AndroidManifest.xml Error:
Namespace 'com.segment.analytics' is used in multiple modules and/or libraries: :segment_analytics, com.segment.analytics.kotlin:android:1.24.1. Please ensure that all modules and libraries have a unique namespace.
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed with multiple errors, see logs
Fix
Rename the plugin's namespace to something unique, e.g. com.segment.analytics.flutter, and drop the deprecated package= attribute from AndroidManifest.xml. The namespace only affects the generated R/BuildConfig package, not the Dart API or Kotlin source packages. We've been running this patch in production: https://github.com/cheddar-me/analytics_flutter/commit/dda9906f4c3aed3c0b220f3c99447fafa2c3ddb8
- Dominant language
- Dart
- Stars
- 33
- Forks
- 57
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from segmentio/analytics_flutter
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
segmentio/analytics_flutter#212 · 2 reactions ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
segmentio/analytics_flutter#204 · 1 reaction ·
-
[Web] getExistingAnonymousId does not decode JSON-stringified ajs_anonymous_id from localStorage Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
segmentio/analytics_flutter#196 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 50/100
segmentio/analytics_flutter#209 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
segmentio/analytics_flutter#199 ·
All issues in segmentio/analytics_flutter
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
code quality good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Suwayomi/Suwayomi-Tsumiru#479 ·
-
Build Failure: agora_rtc_engine compiled against android-31 while dependencies require android-34+ Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
conceptadev/noir#95 ·