Invoke-customs error when switching build tools from version 26 to 27

I’m facing an issue with my Android project after I updated my build tools. It was functioning correctly on build tools version 26, but now I’m encountering an error related to invoke-customs that states it requires a minimum API level of 26.

Currently, I’m using Android Studio version 4.2.2 and have updated all my project dependencies as well. I modified my compile settings from:

sourceCompatibility JavaVersion.VERSION_1_10
targetCompatibility JavaVersion.VERSION_1_10

To this new setup:

compileOptions {
    sourceCompatibility kotlin_version
    targetCompatibility kotlin_version
}

Since making these changes, I’ve been getting errors about invoke-customs. The message indicates that these are only supported with Android API level 26, which I thought was already my target.

Has anyone experienced something similar? What might be causing this issue, and how can I resolve it? I appreciate any support.

hey, you might wanna check your minSdkVersion in build.gradle—make sure it’s set to at least 26+. also, confirm your kotlin_version is not lower than JavaVersion.VERSION_1_8. this might fix your invoke-customs issue.

You’ve got a config mismatch between your build tools and compatibility settings. When you upgraded to build tools 27, you accidentally broke things by using kotlin_version for your targetCompatibility value. That variable probably contains something like “1.3.50” instead of a proper JavaVersion enum, so the compiler gets confused and defaults to an older Java version that can’t handle invoke-customs operations. Fix your compileOptions block by using proper JavaVersion constants. Set both sourceCompatibility and targetCompatibility to JavaVersion.VERSION_1_8 minimum - that’s what supports invoke-customs. Also double-check that your compileSdkVersion matches your build tools version 27. I ran into the same mess when I mixed version strings with JavaVersion enums during my own upgrades.

Had this exact issue last year during an upgrade. Your targetCompatibility is set to kotlin_version, but it should be a JavaVersion constant, not a Kotlin version string. Change it to JavaVersion.VERSION_1_8 instead. The invoke-customs error happens when the compiler tries to use Java 8+ features but your target SDK or compile options are wrong. Also check that your app-level build.gradle has compileSdkVersion set to 27 or higher to match your build tools version.