Kotlin Compilation Error: Primary Constructor call expected occurs when the call to kotlin primary constructor is missing in the definition of kotlin secondary constructor.

This compilation error could be resolved by including a call to the primary constructor, or previous secondary constructors that make a call to the primary constructor, using “this” keyword.

Let us see an example below which recreates Kotlin Primary Constructor call expected – Compile Error

How to handle Kotlin Primary Constructor call expected – Compile Error

Let us include the call to primary constructor or previous secondary constructors that make a call to the primary constructor. The corrected program is given below :

Conclusion

In this Kotlin Tutorial, we have learned how to handle the Kotlin Primary Constructor call expected – Compile Error by including the call to primary constructor using “this” keyword. Learn about Kotlin Secondary Constructor.