# gradle


12/14/2023, 10:52 AM
Hello everyone, hope you are all doing well. I have an android project. It has an app and one module (inside of which there are 4 more modules) In order to manage those modules, I created a convention plugin. To do that, I created a
directory, inside
, then
directory, inside of that
and needed configuration. Inside the
file I defined my plugin. In the
of the project I have
and I use my plugin without issues in the project, everything works just fine. I tried all the gradle tasks and everything was running fine when I used Android Studio's UI tool for runing gradle. BUT, when I attempt to run any task from the terminal, I am getting the following error
Copy code
> Task :conventionPlugins:myplugin:compileKotlin FAILED

FAILURE: Build failed with an exception.  

* What went wrong:
Execution failed for task ':conventionPlugins:myplugin:compileKotlin'.
> Error while evaluating property 'compilerOptions.jvmTarget' of task ':conventionPlugins:myplugin:compileKotlin'.
   > Failed to calculate the value of property 'jvmTarget'.
      > Unknown Kotlin JVM target: 21
This never used to happen before, I was able to run all the tasks from the terminal. Note that this is not an Android module, just a separate project whose build I am including if I understood what I was doing correctly 😄 Of course rolling back to before I had the convention plugin, I can still run the commands from the terminal. When running from terminal I am using
./gradlew clean
for example, meaning the wrapper so why doesn't it take project's java version and takes the one from the system (which is 21 and is not in the compatibility matrix) Note: I am attaching a photo of what I mean when I say running it from Android Studio's UI

Adam S

12/14/2023, 12:05 PM
what version of Gradle are you using? You need 8.5 to run Gradle with Java 21 (although earlier versions of Gradle can build Java 21 projects)
btw running
gradle clean
inside of IntelliJ/Android Studio should use the Gradle wrapper
also what do you have set for 'Gradle JVM' in Android Studio settings? File | Settings | Build, Execution, Deployment | Build Tools | Gradle


12/14/2023, 1:42 PM
I think this can also happen if you don't use the latest Kotlin version (the Kotlin plugin added support for Java 21 after Gradle did)


12/14/2023, 1:51 PM
I am using jdk17 in the projext, had to add it as default in the terminal for it to work
the real question now is why did it work before when i didnt have it
Thought it is probably bcs i added another gradle project it didnt know how to resolve or something