{"record":{"id":"b99327f0210a1f1c","repo":"microg/GmsCore","slug":"no-signature-found-for-packagename","errorCode":null,"errorMessage":"No signature found for $packageName","messagePattern":"No signature found for \\$packageName","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"play-services-auth-api-phone/core/src/main/kotlin/org/microg/gms/auth/phone/SmsRetrieverCore.kt","lineNumber":276,"sourceCode":"                    Log.w(TAG, \"Error handling incoming SMS\", e)\n                }\n            }\n        }\n    }\n\n    private inner class TimeoutReceiver : BroadcastReceiver() {\n        override fun onReceive(context: Context, intent: Intent) {\n            val requestId = intent.getIntExtra(EXTRA_REQUEST_ID, -1)\n            if (requestId != -1) {\n                handleTimeout(requestId)\n            }\n        }\n    }\n\n    @TargetApi(19)\n    fun getHashString(packageName: String): String {\n        val signature =\n            context.packageManager.getSignatures(packageName).firstOrNull()?.toCharsString() ?: throw RuntimeException(\"No signature found for $packageName\")\n        val appInfo = \"$packageName $signature\"\n        val messageDigest = MessageDigest.getInstance(\"SHA-256\")\n        messageDigest.update(appInfo.toByteArray(StandardCharsets.UTF_8))\n        return Base64.encodeToString(messageDigest.digest(), Base64.NO_PADDING or Base64.NO_WRAP).substring(0, 11)\n    }\n\n    private fun anyOtherPackageHasHashString(packageName: String, hashString: String): Boolean {\n        val collision = context.packageManager.getInstalledPackages(0)\n            .firstOrNull { it.packageName != packageName && getHashString(it.packageName) == hashString } ?: return false\n\n        Log.w(TAG, \"Hash string collision between $packageName and ${collision.packageName} (both are $hashString)\")\n        return true\n    }\n\n    private fun isPhoneNumberInContacts(context: Context, phoneNumber: String): Boolean {\n        fun normalizePhoneNumber(input: String): String {\n            var output = \"\"\n            if (!TextUtils.isEmpty(input)) {","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-auth-api-phone/core/src/main/kotlin/org/microg/gms/auth/phone/SmsRetrieverCore.kt#L258-L294","documentation":"getHashString throws 'No signature found for $packageName' when PackageManager.getSignatures(packageName) returns no signatures for the given package. The SMS Retriever hash (the 11-char string embedded in SMS messages) is computed from the package name plus its signing certificate; without a signature the hash cannot be derived.","triggerScenarios":"Calling startSmsRetriever() or anyOtherPackageHasHashString() for a packageName that is not installed, is an instant/incremental app without exposed signatures, or whose signatures are unavailable to the caller (e.g. querying another app's signatures without the QUERY_ALL_PACKAGES / <queries> visibility on Android 11+).","commonSituations":"Typo'd or wrong applicationId passed to startSmsRetriever; calling before the app's first install completes; Android 11+ package visibility filtering hiding the target package; installing via incremental/APK-split mechanisms where signature query returns empty.","solutions":["Pass the calling app's own packageName (context.packageName), not a hard-coded or wrong id","Ensure the app is fully installed before computing the hash","On Android 11+, add the correct <queries> declaration or QUERY_ALL_PACKAGES so the package and its signatures are visible","Wrap in try-catch and fall back to Play Services' SmsRetriever.getClient(...).startSmsRetriever() which handles hashing itself"],"exampleFix":"// before\nval name = \"com.example.wrongid\"\ncore.startSmsRetriever(name)\n// after\nval name = context.packageName\ncore.startSmsRetriever(name)","handlingStrategy":"validation","validationCode":"try { context.packageManager.getPackageInfo(context.packageName, 0) } catch (e: PackageManager.NameNotFoundException) { /* not installed */ }","typeGuard":null,"tryCatchPattern":"try { core.startSmsRetriever(pkg) } catch (e: RuntimeException) { if (e.message?.startsWith(\"No signature found\") == true) usePlayServicesRetriever() else throw e }","preventionTips":["Always pass context.packageName, not a hard-coded id","Declare <queries>/QUERY_ALL_PACKAGES for Android 11+ package visibility","Fall back to Play Services SmsRetriever which computes the hash internally"],"tags":["android","sms-retriever","app-signature","package-visibility"],"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-14T05:17:10.506Z"}