{"record":{"id":"a52b2a070feb7b0b","repo":"microg/GmsCore","slug":"packagename-does-not-have-any-of-permissions","errorCode":null,"errorMessage":"$packageName does not have any of $permissions","messagePattern":"\\$packageName does not have any of \\$permissions","errorType":"exception","errorClass":"SecurityException","httpStatus":null,"severity":"error","filePath":"play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationManagerInstance.kt","lineNumber":415,"sourceCode":"                    Log.w(TAG, \"Failed\", e)\n                }\n            }\n        }\n    }\n\n    // endregion\n\n    private fun getClientIdentity() = ClientIdentity(packageName).apply { uid = getCallingUid(); pid = getCallingPid() }\n\n    private fun checkHasAnyLocationPermission() = checkHasAnyPermission(ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION)\n\n    private fun checkHasAnyPermission(vararg permissions: String) {\n        for (permission in permissions) {\n            if (context.packageManager.checkPermission(permission, packageName) == PERMISSION_GRANTED) {\n                return\n            }\n        }\n        throw SecurityException(\"$packageName does not have any of $permissions\")\n    }\n\n    override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean =\n        warnOnTransactionIssues(code, reply, flags, TAG) { super.onTransact(code, data, reply, flags) }\n}","sourceCodeStart":397,"sourceCodeEnd":420,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationManagerInstance.kt#L397-L420","documentation":"checkHasAnyPermission (used by checkHasAnyLocationPermission) throws SecurityException if the binding app's package declares none of the expected permissions in the package manager. microG refuses to serve a location binder instance to a client that has no location permission declared at all, since every subsequent call would fail. Note it checks declared (installed) permission, not runtime grant state.","triggerScenarios":"A client app binds to the location service (handleServiceRequest path -> LocationManagerInstance construction) while its AndroidManifest lacks ACCESS_COARSE_LOCATION/ACCESS_FINE_LOCATION, so PackageManager.checkPermission returns non-granted for all supplied permissions.","commonSituations":"Manifest missing <uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/> (or COARSE); permission typo; app targeting newer SDK where manifest entries are ignored due to malformed permission tags; instrumented tests binding without declaring permissions.","solutions":["Add <uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/> (and ACCESS_FINE_LOCATION) to the app's AndroidManifest.","Verify installed permission state: adb shell dumpsys package <pkg> | grep LOCATION — reinstall the app after manifest changes.","Fix permission name typos in the manifest (names are case-sensitive)."],"exampleFix":"// before\n// AndroidManifest.xml has no location permission\n// after\n<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\" />\n<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" />","handlingStrategy":"validation","validationCode":"val pm = context.packageManager\nval hasLocation = pm.checkPermission(\"android.permission.ACCESS_COARSE_LOCATION\", context.packageName) == PackageManager.PERMISSION_GRANTED ||\n    pm.checkPermission(\"android.permission.ACCESS_FINE_LOCATION\", context.packageName) == PackageManager.PERMISSION_GRANTED\nif (!hasLocation) throw IllegalStateException(\"Declare ACCESS_FINE/COARSE_LOCATION in the manifest\")","typeGuard":"fun declaresLocationPermission(ctx: Context): Boolean =\n    listOf(\"android.permission.ACCESS_COARSE_LOCATION\", \"android.permission.ACCESS_FINE_LOCATION\")\n        .any { ctx.packageManager.checkPermission(it, ctx.packageName) == PackageManager.PERMISSION_GRANTED }","tryCatchPattern":"try {\n    val instance = LocationServices.getFusedLocationProviderClient(context)\n} catch (e: SecurityException) {\n    if (e.message?.contains(\"does not have any of\") == true) {\n        // manifest lacks location permissions — fix AndroidManifest and reinstall\n    }\n}","preventionTips":["Always declare ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION in AndroidManifest.xml","Reinstall the app after manifest permission changes","Verify with adb shell dumpsys package <pkg> that permissions are declared"],"tags":["security","manifest","permission","location"],"backgroundTag":"permission-denied","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"}