microg/GmsCore · error · IllegalArgumentException

Conflicting data sources found

Error message

Conflicting data sources found

What it means

Thrown by the deprecated DataSet.add(DataPoint) when the DataPoint's DataSource stream identifier does not match the DataSet's DataSource stream identifier. A DataSet can only contain points produced by a single data source, so a mismatched point is rejected to keep the data set consistent.

Source

Thrown at play-services-fitness/src/main/java/com/google/android/gms/fitness/data/DataSet.java:68

    DataSet(@NonNull DataSource dataSource) {
        this.versionCode = 3;
        this.dataSource = dataSource;
        this.rawDataPoints = new ArrayList<>();
        this.uniqueDataSources = new ArrayList<>();
        uniqueDataSources.add(dataSource);
    }

    /**
     * Adds a data point to this data set. The data points should be for the correct data type and data source, and should have its timestamp
     * already set.
     *
     * @throws IllegalArgumentException If dataPoint has invalid data.
     * @deprecated Build {@link DataSet} instances using the builder.
     */
    @Deprecated
    public void add(@NonNull DataPoint dataPoint) {
        if (!dataPoint.getDataSource().getStreamIdentifier().equals(dataSource.getStreamIdentifier()))
            throw new IllegalArgumentException("Conflicting data sources found");
        // TODO
        rawDataPoints.add(dataPoint);
    }

    /**
     * Adds a list of data points to this data set in bulk. All data points should be for the correct data type and data source, and should have their
     * timestamp already set.
     *
     * @deprecated Build {@link DataSet} instances using the builder.
     */
    @Deprecated
    public void addAll(@NonNull Iterable<DataPoint> iterable) {
        for (DataPoint dataPoint : iterable) {
            add(dataPoint);
        }
    }

    /**

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Use DataSet.Builder (DataSet.builder(dataSource)) and add points via Builder.add so the source is enforced consistently.
  2. Ensure every DataPoint is created from exactly the same DataSource instance (or one with an identical stream identifier) as the DataSet.
  3. Give every DataSource used for the same stream the same streamName/streamIdentifier via setStreamName.
  4. Migrate away from the deprecated add() to the builder API, which validates against the correct source.

Example fix

// before
DataSet ds = new DataSet(dataType);
ds.add(pointFromOtherSource); // throws
// after
DataSet ds = DataSet.builder(sharedDataSource).add(pointFromSharedSource).build();
Defensive patterns

Strategy: validation

Validate before calling

if (!dataPoint.getDataSource().getStreamIdentifier().equals(dataSetDataSource.getStreamIdentifier())) throw new IllegalArgumentException("point source mismatch");

Type guard

boolean matchesSource(DataPoint p, DataSource ds) { return p.getDataSource().getStreamIdentifier().equals(ds.getStreamIdentifier()); }

Try / catch

try { dataSet.add(dataPoint); } catch (IllegalArgumentException e) { log.warn("Skipping point from wrong source", e); }

Prevention

When it happens

Trigger: Calling DataSet.add(dataPoint) (the deprecated raw method) where dataPoint.getDataSource().getStreamIdentifier() differs from the stream identifier of the DataSet's own dataSource — typically when mixing points built from different DataSource builders.

Common situations: Building one shared DataSource for a data type but accidentally creating per-point DataSources with different stream names; copying DataPoints between DataSets created from different sources; legacy code paths that bypass DataSet.Builder.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06). Data as JSON: /api/errors/9903587b8c2fe6e5. Report an issue: GitHub.