Skip to content

Android build fails under AGP 9 when analytics-kotlin is also in the dependency graph: duplicate namespace 'com.segment.analytics' #214

Description

@MarcinusX

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_ioio.customer.android:datapipelinescom.segment.analytics.kotlin:android).

Steps to reproduce

  1. Flutter app with segment_analytics: 1.1.12 and AGP 9.x (tested with 9.1.0).
  2. 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"
    }
  3. 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: cheddar-me@dda9906

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions