{"record":{"id":"1c2f968e0b5c89ae","repo":"microg/GmsCore","slug":"integrityerrorcode-network-error","errorCode":"IntegrityErrorCode.NETWORK_ERROR","errorMessage":"DroidGuard failed.","messagePattern":"DroidGuard failed\\.","errorType":"error_code","errorClass":"StandardIntegrityException","httpStatus":null,"severity":"error","filePath":"vending-app/src/main/kotlin/com/google/android/finsky/integrityservice/IntegrityService.kt","lineNumber":180,"sourceCode":"\n                val authToken = getAuthToken(context, AUTH_TOKEN_SCOPE)\n                if (TextUtils.isEmpty(authToken)) {\n                    Log.w(TAG, \"requestIntegrityToken: Got null auth token for type: $AUTH_TOKEN_SCOPE\")\n                }\n                Log.d(TAG, \"requestIntegrityToken authToken: $authToken\")\n\n                val droidGuardData = withContext(Dispatchers.IO) {\n                    val droidGuardResultsRequest = DroidGuardResultsRequest()\n                    droidGuardResultsRequest.bundle.putString(\"thirdPartyCallerAppPackageName\", packageName)\n                    Log.d(TAG, \"Running DroidGuard (flow: $INTEGRITY_FLOW_NAME, data: $data)\")\n                    val droidGuardToken = DroidGuard.getClient(context).getResults(INTEGRITY_FLOW_NAME, data, droidGuardResultsRequest).await()\n                    Log.d(TAG, \"Running DroidGuard (flow: $INTEGRITY_FLOW_NAME, droidGuardToken: $droidGuardToken)\")\n                    Base64.decode(droidGuardToken, Base64.NO_PADDING or Base64.NO_WRAP or Base64.URL_SAFE).toByteString()\n                }\n\n                if (droidGuardData.utf8().startsWith(INTEGRITY_PREFIX_ERROR)) {\n                    Log.w(TAG, \"droidGuardData: ${droidGuardData.utf8()}\")\n                    throw StandardIntegrityException(IntegrityErrorCode.NETWORK_ERROR, \"DroidGuard failed.\")\n                }\n\n                val integrityRequest = IntegrityRequest(\n                    params = integrityParams,\n                    flowName = INTEGRITY_FLOW_NAME,\n                    droidGuardTokenRaw = droidGuardData,\n                    playCoreVersion = playCoreVersion,\n                    playProtectDetails = PlayProtectDetails(PlayProtectState.PLAY_PROTECT_STATE_NO_PROBLEMS),\n                    appAccessRiskDetailsResponse = AppAccessRiskDetailsResponse(\n                        installedAppsSignalDataWrapper = InstalledAppsSignalDataWrapper(\".\"),\n                        screenCaptureSignalDataWrapper = ScreenCaptureSignalDataWrapper(\".\"),\n                        screenOverlaySignalDataWrapper = ScreenOverlaySignalDataWrapper(\".\"),\n                        accessibilityAbuseSignalDataWrapper = AccessibilityAbuseSignalDataWrapper(),\n                        displayListenerMetadataWrapper = DisplayListenerMetadataWrapper(\n                            lastDisplayAddedTimeDelta = makeTimestamp(SystemClock.elapsedRealtimeNanos())\n                        )\n                    )\n                )","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/vending-app/src/main/kotlin/com/google/android/finsky/integrityservice/IntegrityService.kt#L162-L198","documentation":"DroidGuard (Google's on-device attestation/integrity check) returned a payload beginning with the error prefix instead of a usable token, so the service cannot continue and throws IntegrityErrorCode.NETWORK_ERROR with message \"DroidGuard failed.\". This indicates the device-side DroidGuard verdict step failed, typically due to connectivity, device integrity, or Play Services issues.","triggerScenarios":"requestIntegrityToken where the DroidGuard result for flow INTEGRITY_FLOW_NAME decodes to UTF-8 starting with INTEGRITY_PREFIX_ERROR — i.e. DroidGuard itself reports a failure rather than returning a token.","commonSituations":"Device offline or flaky network during the attestation; Play Services/device issues (rooted, unlocked bootloader, unlicensed device); Google Play Services out of date or disabled; transient server-side DroidGuard failures under load.","solutions":["Retry the request with exponential backoff — DroidGuard failures are often transient.","Check network connectivity and that Google Play Services is up to date and enabled on the device.","Catch IntegrityErrorCode.NETWORK_ERROR and surface a retryable state to the user rather than treating it as a policy violation.","Test on a known-good device to rule out device-integrity (root/emulator) causes; escalate to Play Console support if persistent on healthy devices."],"exampleFix":"// before\nintegrityManager.requestIntegrityToken(request)\n// after\ntry {\n    integrityManager.requestIntegrityToken(request)\n} catch (e: StandardIntegrityException) {\n    if (e.errorCode == IntegrityErrorCode.NETWORK_ERROR) {\n        scheduleRetryWithBackoff() // transient DroidGuard failure\n    } else throw e\n}","handlingStrategy":"retry","validationCode":"// No pre-call validation possible; check connectivity first\nval cm = context.getSystemService(ConnectivityManager::class.java)\nval online = cm.activeNetwork?.let { cm.getNetworkCapabilities(it)?.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED) } == true","typeGuard":null,"tryCatchPattern":"try {\n    integrityManager.requestIntegrityToken(request)\n} catch (e: StandardIntegrityException) {\n    if (e.errorCode == IntegrityErrorCode.NETWORK_ERROR) {\n        retryWithExponentialBackoff(maxAttempts = 3)\n    } else throw e\n}","preventionTips":["Implement exponential-backoff retries for NETWORK_ERROR from integrity calls","Verify Google Play Services is installed and updated on target devices","Distinguish transient network errors from permanent device-integrity failures in telemetry","Test on healthy physical devices to rule out root/emulator causes"],"tags":["play-integrity","android","droidguard","network","attestation"],"backgroundTag":"network-request-failed","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"}