microg/GmsCore · error · IllegalArgumentException

An empty path was supplied.

Error message

An empty path was supplied.

What it means

PutDataRequest.create(String path) validates the path before building a wear:// Uri. An empty or null path cannot form a valid wear URI, so the library throws IllegalArgumentException("An empty path was supplied.").

Source

Thrown at play-services-wearable/src/main/java/com/google/android/gms/wearable/internal/PutDataRequest.java:69

    long syncDeadline = DEFAULT_SYNC_DEADLINE;

    private PutDataRequest() {
        uri = null;
        assets = new Bundle();
    }

    private PutDataRequest(Uri uri) {
        this.uri = uri;
        assets = new Bundle();
    }

    public static PutDataRequest create(Uri uri) {
        return new PutDataRequest(uri);
    }

    public static PutDataRequest create(String path) {
        if (TextUtils.isEmpty(path)) {
            throw new IllegalArgumentException("An empty path was supplied.");
        } else if (!path.startsWith("/")) {
            throw new IllegalArgumentException("A path must start with a single / .");
        } else if (path.startsWith("//")) {
            throw new IllegalArgumentException("A path must start with a single / .");
        } else {
            return create((new Uri.Builder()).scheme(WEAR_URI_SCHEME).path(path).build());
        }
    }

    public static PutDataRequest createFromDataItem(DataItem source) {
        PutDataRequest dataRequest = new PutDataRequest(source.getUri());
        dataRequest.data = source.getData();
        // TODO: assets
        return dataRequest;
    }

    public static PutDataRequest createWithAutoAppendedId(String pathPrefix) {
        return new PutDataRequest(null);

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Check the path for null/emptiness before calling create and provide a valid path starting with '/'.
  2. Log the source of the path value to find why it is empty.
  3. Provide a default path constant instead of dynamic construction.

Example fix

// before
PutDataRequest request = PutDataRequest.create(path);

// after
if (path == null || path.isEmpty()) {
    throw new IllegalStateException("path must be set before syncing");
}
PutDataRequest request = PutDataRequest.create(path);
Defensive patterns

Strategy: validation

Validate before calling

if (TextUtils.isEmpty(path)) { throw new IllegalArgumentException("path required"); }

Try / catch

try {
    PutDataRequest.create(path);
} catch (IllegalArgumentException e) {
    Log.e(TAG, "empty path", e);
}

Prevention

When it happens

Trigger: Calling PutDataRequest.create("") or PutDataRequest.create(null) — any path that TextUtils.isEmpty treats as empty.

Common situations: Building the path dynamically from a database value or user input that is empty; forgetting to set a constant path field; concatenating segments where the variable part is missing.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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