microg/GmsCore · error · SecurityException

$packageName does not have any of $permissions

Error message

$packageName does not have any of $permissions

What it means

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.

Source

Thrown at play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationManagerInstance.kt:415

                    Log.w(TAG, "Failed", e)
                }
            }
        }
    }

    // endregion

    private fun getClientIdentity() = ClientIdentity(packageName).apply { uid = getCallingUid(); pid = getCallingPid() }

    private fun checkHasAnyLocationPermission() = checkHasAnyPermission(ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION)

    private fun checkHasAnyPermission(vararg permissions: String) {
        for (permission in permissions) {
            if (context.packageManager.checkPermission(permission, packageName) == PERMISSION_GRANTED) {
                return
            }
        }
        throw SecurityException("$packageName does not have any of $permissions")
    }

    override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean =
        warnOnTransactionIssues(code, reply, flags, TAG) { super.onTransact(code, data, reply, flags) }
}

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Add <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> (and ACCESS_FINE_LOCATION) to the app's AndroidManifest.
  2. Verify installed permission state: adb shell dumpsys package <pkg> | grep LOCATION — reinstall the app after manifest changes.
  3. Fix permission name typos in the manifest (names are case-sensitive).

Example fix

// before
// AndroidManifest.xml has no location permission
// after
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Defensive patterns

Strategy: validation

Validate before calling

val pm = context.packageManager
val hasLocation = pm.checkPermission("android.permission.ACCESS_COARSE_LOCATION", context.packageName) == PackageManager.PERMISSION_GRANTED ||
    pm.checkPermission("android.permission.ACCESS_FINE_LOCATION", context.packageName) == PackageManager.PERMISSION_GRANTED
if (!hasLocation) throw IllegalStateException("Declare ACCESS_FINE/COARSE_LOCATION in the manifest")

Type guard

fun declaresLocationPermission(ctx: Context): Boolean =
    listOf("android.permission.ACCESS_COARSE_LOCATION", "android.permission.ACCESS_FINE_LOCATION")
        .any { ctx.packageManager.checkPermission(it, ctx.packageName) == PackageManager.PERMISSION_GRANTED }

Try / catch

try {
    val instance = LocationServices.getFusedLocationProviderClient(context)
} catch (e: SecurityException) {
    if (e.message?.contains("does not have any of") == true) {
        // manifest lacks location permissions — fix AndroidManifest and reinstall
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06). Data as JSON: /api/errors/a52b2a070feb7b0b. Report an issue: GitHub.