Invoke-customs are only supported starting with Android O ( — min-api 26) — Solution

Page content

Error

Error Screenshot

The stack trace log is:

Error: Invoke-customs are only supported starting with Android O (--min-api 26)

Reason

Possibly, one of the reason for this Invoke-customs support error is using the Lambda functions/Expressions instead of inline callbacks as the Lambda functions/Expressions are introduced in Java 8 and application must be compatible with Java 8 to use them.

There might be many other reasons behind the error, the above one is something I understood. If you know anymore info/reasons regarding the error, let me know in comments I will update them in the article.

Solution -1 (Tested and Working)

Adding the below snippet in build.gradle(App level)

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }        
}

Error Screenshot

I have tested this solution and it resolves the error.

Solution 2 (Not Tested)

Disable ‘Instant Run’.

Android Studio -> File -> Settings -> Build, Execution, Deployment -> Instant Run -> Disable checkbox

I’m unable to test this solution as option for Disabling Instant Run is not available in current Android Studio version (3.6.2). Instant Run is directly available with ‘Run App’ option.


That’s all about “Invoke-customs are only supported starting with Android O ( — min-api 26)” Error and its solution. Please do let me know Any info regarding this error I have missed in this article and any other solutions to resolve this error in comments. I will update them in the article.