0
0
KotlinDebug / FixBeginner · 3 min read

Fix 'None of the following functions can be called' Error in Kotlin

The none of the following functions can be called error in Kotlin happens when you call a function with arguments that don't match any available function signature. To fix it, check the function name, argument types, and number of parameters to ensure they exactly match a defined function.
🔍

Why This Happens

This error occurs when Kotlin cannot find any function that matches the name and the types or number of arguments you provided. It means you are trying to call a function, but none of the versions (overloads) of that function accept the arguments you gave.

kotlin
fun greet(name: String) {
    println("Hello, $name")
}

fun main() {
    greet(123) // Trying to call greet with an Int instead of String
}
Output
Error: None of the following functions can be called with the arguments supplied. fun greet(name: String): Unit defined in root package Type mismatch: inferred type is Int but String was expected
🔧

The Fix

Make sure the arguments you pass match the function's parameters exactly in type and count. In this example, greet expects a String, so pass a string value instead of an integer.

kotlin
fun greet(name: String) {
    println("Hello, $name")
}

fun main() {
    greet("Alice") // Correct call with a String
}
Output
Hello, Alice
🛡️

Prevention

To avoid this error, always check the function signature before calling it. Use your IDE's autocomplete and type hints to ensure argument types match. Writing clear function definitions and using named arguments can help prevent mismatches. Also, keep your code and libraries updated to avoid calling outdated or removed functions.

⚠️

Related Errors

  • Type mismatch: Passing wrong data types to functions.
  • Unresolved reference: Calling a function that does not exist or is not imported.
  • Overload resolution ambiguity: Multiple functions match the call equally well, causing confusion.

Key Takeaways

Check that function arguments exactly match the expected types and number of parameters.
Use your IDE's autocomplete to avoid calling functions incorrectly.
Pass correct data types to functions to prevent this error.
Keep function names and signatures consistent and clear.
Use named arguments to improve code clarity and reduce mistakes.