Common Mistakes & Compiler Errors
Fix the typical 'no actual declaration' failures.
Common Mistakes & Compiler Errors is a free Kotlin Multiplatform Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Kotlin Multiplatform Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Errors Are Your Friend
expect/actual mistakes surface at compile time, never as silent runtime bugs. Learning the messages makes fixing them fast. 🛠️
No actual Declaration
The most common error is forgetting an actual for one target. The compiler says expected declaration has no actual for that platform.
Fix the Missing actual
Add the implementation in the right source set, like iosMain. Once every target has its actual, the build goes green.
actual fun platform(): String = "iOS"Signature Mismatch
If your actual changes the return type or parameters, the compiler reports that the actual does not match the expect. Align them exactly.
Forgetting the actual Keyword
An implementation without the actual keyword looks like a separate function to the compiler, so it still complains the expect is unfulfilled.
Wrong Source Set
Putting an actual in the wrong folder means a target still has no match. Each actual must sit in its platform's source set.
Package Must Match
The actual has to share the exact package of its expect. A mismatched package leaves the expect looking unimplemented.
package com.app.coreImporting Platform Types in Common
Using Android's Build or iOS UIDevice inside commonMain fails to resolve. Keep platform imports inside their own source sets only.
Default Args Belong on expect
Declare default parameter values on the expect, not the actual. Repeating defaults on an actual triggers a compiler error.
Read the Message Carefully
Kotlin's errors usually name the exact target and member. Treat the message as a checklist and the fix is almost always obvious. 💡
Build All Targets
Compile every target, not just Android. An iOS-only gap stays hidden until you build the iOS framework as well.
Quick Check
Spot the cause of the classic error.
Recap
You can now diagnose the usual expect/actual failures: a missing actual, a signature or package mismatch, or a platform import in common code. 🎉
Frequently asked questions
Is the “Common Mistakes & Compiler Errors” lesson free?
Yes — the full text of “Common Mistakes & Compiler Errors” is free to read here on the web, and the Kotlin Multiplatform Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Kotlin Multiplatform Academy course, upgrade to CoddyKit PRO.
What will I learn in “Common Mistakes & Compiler Errors”?
Fix the typical 'no actual declaration' failures. You practise Kotlin Multiplatform Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Kotlin Multiplatform Academy?
No prior experience is required. Kotlin Multiplatform Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Common Mistakes & Compiler Errors” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Kotlin Multiplatform Academy lesson?
Yes. Every Kotlin Multiplatform Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Why expect/actual Exists
- Get the Platform Name per Target
- expect/actual Classes & Properties
- Common Mistakes & Compiler Errors