Explicit API mode makes public Kotlin APIs deliberate: declarations must state their visibility and public properties or functions must state their types. This helps library authors avoid accidental exposure and later breaking changes. section 4.1.3
Declare a public API explicitly
Enable the mode with `-Xexplicit-api=strict` or `-Xexplicit-api=warning`. Then write public declarations with both parts visible: `public fun greet(name: String): String = "Hello, $name"`. Kotlin otherwise makes unspecified visibility public, unlike Java's package-private default. section 4.1.3
Explicit API mode checks:
- Visibility for declarations exposed as public API. section 4.1.3
- Explicit types for public properties and functions. section 4.1.3
- Strict or warning enforcement through the compiler or build system. section 4.1.3
Table 4.2 Kotlin visibility modifiers (view table figure)
Use the visibility table to compare public, internal, protected, and private boundaries when deciding which declarations require explicit API treatment. section 4.1.3
