microg/GmsCore · error · IllegalArgumentException

Service not supported.

Error message

Service not supported.

What it means

GcmNetworkManager.validateService throws IllegalArgumentException when the provided service name is not among the services resolved for ACTION_TASK_READY. I.e. some GcmTaskService exists in the app, but not the specific one named.

Source

Thrown at play-services-gcm/src/main/java/com/google/android/gms/gcm/GcmNetworkManager.java:242

            pm.getPackageInfo(packageName, 0);
            return true;
        } catch (PackageManager.NameNotFoundException e) {
            return false;
        }
    }

    private void validateService(String serviceName) {
        if (serviceName == null) throw new NullPointerException("No service provided");
        Intent taskIntent = new Intent(ACTION_TASK_READY);
        taskIntent.setPackage(context.getPackageName());
        PackageManager pm = context.getPackageManager();
        List<ResolveInfo> serviceResolves = pm.queryIntentServices(taskIntent, 0);
        if (serviceResolves == null || serviceResolves.isEmpty())
            throw new IllegalArgumentException("No service found");
        for (ResolveInfo info : serviceResolves) {
            if (serviceName.equals(info.serviceInfo.name)) return;
        }
        throw new IllegalArgumentException("Service not supported.");
    }
}

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Pass exactly the GcmTaskService subclass declared in your manifest with the ACTION_TASK_READY intent filter.
  2. Compare the class name against the list of services in the merged manifest.
  3. Fix the service's intent-filter so the intended class is resolvable for ACTION_TASK_READY.

Example fix

// before
gcmNetworkManager.cancelTask(tag, SomeOtherService.class); // "Service not supported."

// after
gcmNetworkManager.cancelTask(tag, MyTaskService.class); // the manifest-registered GcmTaskService
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the class passed is the manifest-declared GcmTaskService
PackageManager pm = getPackageManager();
List<ResolveInfo> list = pm.queryIntentServices(
    new Intent("com.google.android.gms.gcm.ACTION_TASK_READY").setPackage(getPackageName()), 0);
boolean supported = false;
for (ResolveInfo ri : list) {
    if (MyTaskService.class.getName().equals(ri.serviceInfo.name)) { supported = true; break; }
}

Type guard

boolean isRegisteredTaskService(Class<?> c) { return GcmTaskService.class.isAssignableFrom(c); }

Try / catch

try {
    manager.cancelTask(tag, MyTaskService.class);
} catch (IllegalArgumentException e) {
    Log.e(TAG, "Service not registered for GCM tasks");
}

Prevention

When it happens

Trigger: Calling cancelTask(tag, WrongService.class) or scheduling with a class whose name doesn't match any manifest service with the ACTION_TASK_READY intent filter.

Common situations: Passing the Application class or an unrelated Service class; typo in the class reference; a service declared in the manifest without the correct intent filter so it isn't in the resolved list; refactoring that renamed the service class but not all call sites.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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