permissions-dispatcher/PermissionsDispatcher · error · NoParametersAllowedException
Method '${e.simpleString()}()' must not have any parameters
Error message
Method '${e.simpleString()}()' must not have any parameters What it means
Thrown by checkMethodParameters in Validators.kt:95 via NoParametersAllowedException. When the expected parameter count for the annotation is zero, the annotated method must declare no parameters; the generated dispatcher constructs the call itself and has nothing to pass.
Source
Thrown at processor/src/main/kotlin/permissions/dispatcher/processor/util/Validators.kt:95
*/
fun checkMethodSignature(items: List<ExecutableElement>) {
items.forEach {
// Allow 'void' return type only
if (it.returnType.kind != TypeKind.VOID) {
throw WrongReturnTypeException(it)
}
// Allow methods without 'throws' declaration only
if (it.thrownTypes.isNotEmpty()) {
throw NoThrowsAllowedException(it)
}
}
}
fun checkMethodParameters(items: List<ExecutableElement>, numParams: Int, requiredType: TypeMirror? = null) {
items.forEach {
val params = it.parameters
if (numParams == 0 && params.isNotEmpty()) {
throw NoParametersAllowedException(it)
}
if (requiredType == null) {
return
}
if (numParams < params.size) {
throw WrongParametersException(it, numParams, requiredType)
}
// maximum params size is 1
params.forEach { param ->
if (!TYPE_UTILS.isSameType(param.asType(), requiredType)) {
throw WrongParametersException(it, numParams, requiredType)
}
}
}
}
fun <A : Annotation> checkMixPermissionType(items: List<ExecutableElement>, annotationClass: Class<A>) {
items.forEach {View on GitHub (pinned to 74b532bf1f)
Solutions
- Remove all parameters from the annotated method and access needed values via fields or capture them elsewhere.
- Create a parameterless wrapper method that carries the annotation and calls the parameterized helper.
- Move to an annotation variant that permits parameters if the library version supports it.
Example fix
// before
@NeedsPermission(Manifest.permission.CAMERA)
fun showCamera(activity: Activity) { ... }
// after
@NeedsPermission(Manifest.permission.CAMERA)
fun showCamera() { /* use fields/this for context */ } Defensive patterns
Strategy: validation
Validate before calling
@NeedsPermission(Manifest.permission.CAMERA)
fun showCamera() { } // zero parameters for zero-param annotations Try / catch
try {
build()
} catch (e: CompilationError) {
logger.error("Annotated method must not take parameters", e)
} Prevention
- Keep annotated methods parameterless unless the annotation documents parameters.
- Pass context via fields or the enclosing class.
- Wrap parameterized logic in a plain helper method.
When it happens
Trigger: Annotating a method that takes parameters with an annotation whose numParams is 0, e.g. @NeedsPermission on fun showCamera(context: Context) or any annotated method with parameters where the annotation expects none.
Common situations: Keeping existing method parameters after adding the permission annotation; annotating a helper method with parameters by mistake; misunderstanding that @NeedsPermission methods must be parameterless (use @OnNeverAskAgain-style constants or fields instead).
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Method '${e.simpleString()}()' must has less than or equal t
- '${TypeName.get(type)}' can't be annotated with '@RuntimePer
- $value is duplicated in '${e.simpleString()}()' annotated wi
- Annotated class '${rpe.inputClassName}' doesn't have any met
- Method '${e.simpleString()}()' annotated with '@${annotation
AI-assisted analysis of permissions-dispatcher/PermissionsDispatcher@74b532bf1f (2026-09-08).
Data as JSON: /api/errors/15aa5cae8fd26ae7.
Report an issue: GitHub.