{"record":{"id":"27962f82b8db0777","repo":"microg/GmsCore","slug":"no-service-provided","errorCode":null,"errorMessage":"No service provided","messagePattern":"No service provided","errorType":"validation","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"play-services-gcm/src/main/java/com/google/android/gms/gcm/GcmNetworkManager.java","lineNumber":232,"sourceCode":"        if (!packageExists(GMS_PACKAGE_NAME)) return null;\n        Intent scheduleIntent = new Intent(ACTION_SCHEDULE);\n        scheduleIntent.setPackage(GMS_PACKAGE_NAME);\n        scheduleIntent.putExtra(\"app\", PendingIntent.getBroadcast(context, 0, new Intent(), 0));\n        return scheduleIntent;\n    }\n\n    private boolean packageExists(String packageName) {\n        try {\n            PackageManager pm = context.getPackageManager();\n            pm.getPackageInfo(packageName, 0);\n            return true;\n        } catch (PackageManager.NameNotFoundException e) {\n            return false;\n        }\n    }\n\n    private void validateService(String serviceName) {\n        if (serviceName == null) throw new NullPointerException(\"No service provided\");\n        Intent taskIntent = new Intent(ACTION_TASK_READY);\n        taskIntent.setPackage(context.getPackageName());\n        PackageManager pm = context.getPackageManager();\n        List<ResolveInfo> serviceResolves = pm.queryIntentServices(taskIntent, 0);\n        if (serviceResolves == null || serviceResolves.isEmpty())\n            throw new IllegalArgumentException(\"No service found\");\n        for (ResolveInfo info : serviceResolves) {\n            if (serviceName.equals(info.serviceInfo.name)) return;\n        }\n        throw new IllegalArgumentException(\"Service not supported.\");\n    }\n}\n","sourceCodeStart":214,"sourceCodeEnd":245,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-gcm/src/main/java/com/google/android/gms/gcm/GcmNetworkManager.java#L214-L245","documentation":"GcmNetworkManager.validateService throws NullPointerException when the service class name passed in is null. Every public API that routes work to a GcmTaskService (schedule, cancelTask, cancelAllTasks) must supply a concrete service component; a null name is unusable.","triggerScenarios":"Passing a null service class/name into schedule/cancelTask/cancelAllTasks paths, e.g. getClass().getName() on a null reference resolved earlier, or a config field left unset.","commonSituations":"Service class reference conditioned on build flavor or remote config that resolved to null; refactoring that removed the service but left a variable unset.","solutions":["Pass a concrete GcmTaskService subclass: GcmNetworkManager.cancelTask(tag, MyTaskService.class).","Ensure the constant/config holding the service class name is initialized before use.","Verify the service exists in AndroidManifest.xml with the ACTION_TASK_READY intent filter."],"exampleFix":"// before\nString svc = flavorConfig.get(\"taskService\"); // null\ngcmNetworkManager.cancelTask(tag, svc); // NPE\n\n// after\nClass<? extends GcmTaskService> svc = MyTaskService.class;\ngcmNetworkManager.cancelTask(tag, svc);","handlingStrategy":"type-guard","validationCode":"if (serviceClass == null) {\n    throw new IllegalStateException(\"GcmTaskService class must be configured\");\n}","typeGuard":"boolean hasService(Class<?> c) { return c != null && GcmTaskService.class.isAssignableFrom(c); }","tryCatchPattern":"try {\n    manager.cancelAllTasks(MyTaskService.class);\n} catch (NullPointerException e) {\n    Log.e(TAG, \"No service configured\");\n}","preventionTips":["Reference the service class as a compile-time constant, not runtime config","Never derive the service name from nullable configuration","Keep a single constant for the service class"],"tags":["gcm","android","null-pointer","service"],"backgroundTag":"null-argument","analyzedSha":"157c9d86ac46c195a86c2f15ab55c84036223f95","analyzedAt":"2026-09-06T17:27:33.892Z","contentChangedAt":"2026-09-06T17:27:33.892Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}