Avatar ·

Error "Default interface methods are only supported starting with Android 7.0 (Nougat)" in Kotlin

Hello everyone! I'm a beginner in Kotlin and Android development, and I encountered an unclear error when compiling my project. I'm using Android Studio, targetSdkVersion 34, minSdkVersion 21.

\n\n

I have an interface with a default method:

\n\n
interface PaymentCallback {\n    fun onSuccess(transactionId: String)\n    fun onError(error: String)\n    fun onProgress(percent: Int) {\n        // Default implementation - log the progress\n        Log.d("Payment", "Progress: $percent%")\n    }\n}
\n\n

And a class that implements it:

\n\n
class MainActivity : AppCompatActivity(), PaymentCallback {\n    override fun onSuccess(transactionId: String) {\n        Toast.makeText(this, "Payment successful: $transactionId", Toast.LENGTH_LONG).show()\n    }\n\n    override fun