{"record":{"id":"eb8ba63c3e5e096a","repo":"microg/GmsCore","slug":"error-missing-instanceid-service","errorCode":"ERROR_MISSING_INSTANCEID_SERVICE","errorMessage":"ERROR_MISSING_INSTANCEID_SERVICE","messagePattern":"ERROR_MISSING_INSTANCEID_SERVICE","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"critical","filePath":"play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdRpc.java","lineNumber":279,"sourceCode":"            intent.setPackage(\"com.google.example.invalidpackage\");\n            selfAuthToken = PendingIntent.getBroadcast(context, 0, intent, 0);\n        }\n        return selfAuthToken;\n    }\n\n    private static synchronized String getRequestId() {\n        return Integer.toString(lastRequestId++);\n    }\n\n    private void sendRegisterMessage(Bundle data, KeyPair keyPair, String requestId) throws IOException {\n        long elapsedRealtime = SystemClock.elapsedRealtime();\n        if (nextAttempt != 0 && elapsedRealtime <= nextAttempt) {\n            Log.w(TAG, \"Had to wait for \" + interval + \", that's still \" + (nextAttempt - elapsedRealtime));\n            throw new IOException(ERROR_BACKOFF);\n        }\n        initialize();\n        if (iidPackageName == null) {\n            throw new IOException(ERROR_MISSING_INSTANCEID_SERVICE);\n        }\n        Intent intent = new Intent(ACTION_C2DM_REGISTER);\n        intent.setPackage(iidPackageName);\n        data.putString(EXTRA_GMS_VERSION, Integer.toString(getGmsVersionCode(context)));\n        data.putString(EXTRA_OS_VERSION, Integer.toString(SDK_INT));\n        data.putString(EXTRA_APP_VERSION_CODE, Integer.toString(getSelfVersionCode(context)));\n        data.putString(EXTRA_APP_VERSION_NAME, getSelfVersionName(context));\n        data.putString(EXTRA_CLIENT_VERSION, \"iid-\" + GMS_VERSION_CODE);\n        data.putString(EXTRA_APP_ID, InstanceID.sha1KeyPair(keyPair));\n        String pub = base64encode(keyPair.getPublic().getEncoded());\n        data.putString(EXTRA_PUBLIC_KEY, pub);\n        data.putString(EXTRA_SIGNATURE, sign(keyPair, context.getPackageName(), pub));\n        intent.putExtras(data);\n        intent.putExtra(EXTRA_APP, getSelfAuthToken());\n        sendRequest(intent, requestId);\n    }\n\n    private static String sign(KeyPair keyPair, String... payload) {","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdRpc.java#L261-L297","documentation":"InstanceIdRpc.sendRegisterMessage throws ERROR_MISSING_INSTANCEID_SERVICE when initialize() cannot resolve any package on the device that hosts the instance-ID registration service (ACTION_INSTANCE_ID_SERVICE / the IID receiver). Without a provider app (Play Services or microG) the registration intent has no target package.","triggerScenarios":"Calling getToken on a device with no Google Play Services (or an outdated/broken install), or on a microG build where the com.google.android.gms IID service component is missing or disabled, so iidPackageName remains null after initialize().","commonSituations":"Running a GCM/FCM-dependent app on devices without Play Services (e.g. Kindle, emulators without Google APIs, de-Googled ROMs without microG installed); Play Services mid-update or disabled by the user; wrong build variant relying on microG that isn't configured.","solutions":["Verify Google Play Services is installed and up to date on the device (check GooglePlayServicesUtil.isGooglePlayServicesAvailable / ensure updated via the provider)","Ensure the device/setup provides the IID service: on de-Googled devices install and configure microG with the required GMS components","If supporting devices without Play Services, use an alternate push transport (e.g. UnifiedPush) instead of InstanceID/GCM","Check that the app depends on a compatible com.google.android.gms:play-services-iid version matching the device's GMS"],"exampleFix":"// before\nString token = InstanceID.getInstance(ctx).getToken(senderId, \"GCM\");\n// after\nint status = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(ctx);\nif (status != ConnectionResult.SUCCESS) {\n    GoogleApiAvailability.getInstance().getErrorDialog(activity, status, REQ).show();\n    return;\n}\nString token = InstanceID.getInstance(ctx).getToken(senderId, \"GCM\");","handlingStrategy":"validation","validationCode":"int status = GoogleApiAvailability.getInstance()\n    .isGooglePlayServicesAvailable(context);\nif (status != ConnectionResult.SUCCESS) {\n    GoogleApiAvailability.getInstance()\n        .getErrorDialog(activity, status, 0).show();\n}","typeGuard":null,"tryCatchPattern":"try {\n    String token = instanceId.getToken(senderId, \"GCM\");\n} catch (IOException e) {\n    if (\"ERROR_MISSING_INSTANCEID_SERVICE\".equals(e.getMessage())) {\n        promptUserToInstallOrUpdatePlayServices();\n    }\n}","preventionTips":["Check Play Services availability at app startup with GoogleApiAvailability","Test on devices/emulators without Google APIs","Offer a non-GMS push fallback (e.g. UnifiedPush) for de-Googled devices"],"tags":["android","play-services","microg","missing-service"],"backgroundTag":"resource-not-found","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"}