I’m experiencing an issue with my Android project following some updates. I initially used build tools version 26, but I recently upgraded to version 27.
Currently, I’m using Android Studio 4.2.2, and I’ve updated all my dependencies. Additionally, I altered my compile options from:
Now, I’m encountering an error stating that invoke-customs are only supported starting with a minimum API level of 26. This error began occurring after I made the configuration changes. Can anyone shed light on what might be causing this and how I can resolve it? It seems related to API level requirements, but I’m unsure of the best approach to fix the issue.
The invoke-customs error you’re facing typically indicates a mismatch between your Java version and the minimum API level. You’re currently using kotlin_version for targetCompatibility, which is incorrect; it should utilize a JavaVersion constant. I recommend reverting to sourceCompatibility JavaVersion.VERSION_1_8 and targetCompatibility JavaVersion.VERSION_1_8. API level 26 supports Java 8 features adequately, but using a higher version can complicate things with desugaring. Additionally, review your updated dependencies, as they may have been compiled with newer Java versions, leading to this error despite correct compile options. I encountered a similar issue after updating my dependencies, and switching back to Java 8 compatibility resolved it instantly.
your compile options look off. you’re using kotlin_version for java compatibility when it should be for the kotlin compiler. switch back to VERSION_1_8 instead of 1_10 - that’s what most projects use with API 26. the invoke-customs error pops up when your bytecode targets a newer java version than your min sdk can handle.
This happens when your compile target and minimum SDK don’t match up. You’re setting targetCompatibility to kotlin_version - that’s the problem right there. Compile options need Java version constants, not Kotlin version strings. Build tools version 27 made the compiler way stricter about bytecode compatibility. I ran into this exact issue last year during a project migration. Just switch back to JavaVersion.VERSION_1_8 for both source and target compatibility. Also check if any updated dependencies added lambda expressions or method references that need desugaring. Make sure your gradle plugin version matches your build tools version - mismatched versions mess up bytecode generation.