permissions-dispatcher/PermissionsDispatcher · error · NoAnnotatedMethodsException
Annotated class '${rpe.inputClassName}' doesn't have any met
Error message
Annotated class '${rpe.inputClassName}' doesn't have any method annotated with '@${type.simpleName}' What it means
Thrown by checkNotEmpty in Validators.kt:55. A class annotated with @RuntimePermissions must contain at least one method annotated with the given annotation (e.g. @NeedsPermission). If the list of annotated methods is empty, NoAnnotatedMethodsException is thrown because there is nothing useful to generate.
Source
Thrown at processor/src/main/kotlin/permissions/dispatcher/processor/util/Validators.kt:55
val allItems: HashSet<List<String>> = hashSetOf()
items.forEach {
val permissionValue = it.getAnnotation(annotationClass).permissionValue().sorted()
if (allItems.contains(permissionValue)) {
throw DuplicatedValueException(permissionValue, it, annotationClass)
} else {
allItems.add(permissionValue)
}
}
}
/**
* Checks the elements in the provided list for elements.
* <p>
* Raises an exception if it doesn't contain any elements.
*/
fun <A : Annotation> checkNotEmpty(items: List<ExecutableElement>, rpe: RuntimePermissionsElement, annotationClass: Class<A>) {
if (items.isEmpty()) {
throw NoAnnotatedMethodsException(rpe, annotationClass)
}
}
/**
* Checks the elements in the provided list annotated with an annotation
* against private modifiers.
* <p>
* Raises an exception if any element contains the "private" modifier.
*/
fun <A : Annotation> checkPrivateMethods(items: List<ExecutableElement>, annotationClass: Class<A>) {
items.forEach {
if (it.modifiers.contains(Modifier.PRIVATE)) {
throw PrivateMethodException(it, annotationClass)
}
}
}
/**View on GitHub (pinned to 74b532bf1f)
Solutions
- Add at least one method annotated with @NeedsPermission to the annotated class.
- Remove the @RuntimePermissions annotation if no permission methods are needed.
- Ensure the annotated methods live in the same class as @RuntimePermissions and use the correct annotation import.
Example fix
// before
@RuntimePermissions
class MyActivity : AppCompatActivity() { }
// after
@RuntimePermissions
class MyActivity : AppCompatActivity() {
@NeedsPermission(Manifest.permission.CAMERA)
fun showCamera() { }
} Defensive patterns
Strategy: validation
Validate before calling
@RuntimePermissions
class MyActivity : AppCompatActivity() {
@NeedsPermission(Manifest.permission.CAMERA)
fun showCamera() { }
} Try / catch
try {
compile()
} catch (e: CompilationError) {
logger.error("Class annotated with @RuntimePermissions has no @NeedsPermission methods", e)
} Prevention
- Always pair @RuntimePermissions with at least one @NeedsPermission method.
- Remove class-level annotation when the last permission method is deleted.
- Keep permission methods in the same annotated class, not a base class.
When it happens
Trigger: @RuntimePermissions on a class whose body has no @NeedsPermission methods; deleting or renaming the only annotated method; annotating methods in a different class than the one carrying @RuntimePermissions.
Common situations: Removing the last @NeedsPermission method during refactoring while leaving the class-level annotation; moving permission methods into a base class or helper; typo in the method annotation so the processor does not see it.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- '${TypeName.get(type)}' can't be annotated with '@RuntimePer
- $value is duplicated in '${e.simpleString()}()' annotated wi
- Method '${e.simpleString()}()' annotated with '@${annotation
- Method '${e.simpleString()}()' must specify return type 'voi
- Method '${e.simpleString()}()' must not have any 'throws' de
AI-assisted analysis of permissions-dispatcher/PermissionsDispatcher@74b532bf1f (2026-09-08).
Data as JSON: /api/errors/0075018c6ce74aa5.
Report an issue: GitHub.