Gradle 6.7 introduced Java toolchains support. Replace the placeholder with the JDK version you would like to use: If you use versions less than 8.1.0-alpha09, you need to configure targetCompatibility manually via compileOptions. Nevertheless, because of this issue, AGP did not set targetCompatibility to be equal to the toolchain's JDK until the version 8.1.0-alpha09. Gradle Java toolchain support is available only from AGP 7.4.0. To use Gradle toolchain support, use the Android Gradle plugin (AGP) version 8.1.0-alpha09 or higher. Gradle Java toolchains supportĪ warning for Android users. Configure a toolchain to solve this issue. In this case, you have to use Java 17 in your main project to add this library, even though the bytecode's version is 1.8. Assuming that your JDK version is 17, your published library artifact will declare itself compatible with JDK 17+: =17, which is wrong. The targetCompatibility equals the current Gradle's JDK version, which is equal to your JDK version (unless you use a Java toolchain approach). When there is no explicit information about the jvmTarget value in the build script, its default value is null, and the compiler translates it to the default value 1.8. You can also configure it at task level in your adle(.kts) file: Ignore – the plugin skips the check and doesn't produce any messages. Warning – the plugin prints a warning message the default value for projects on Gradle less than 8.0. For example: the compileKotlin task has jvmTarget=1.8, and the compileJava task has (or inherits) targetCompatibility=15.Ĭonfigure the behavior of this check for the whole project by setting the .mode property in the adle(.kts) file to:Įrror – the plugin fails the build the default value for projects on Gradle 8.0+. Different values of the jvmTarget attribute in the kotlin extension or task and targetCompatibility in the java extension or task cause JVM target incompatibility. Main and test source set compile tasks are not related.įor related tasks like these, the Kotlin Gradle plugin checks for JVM target compatibility. In the build module, you may have related compile tasks, for example: } Check for JVM target compatibility of related compile tasks
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |