Kotlin Multiplatform, desktopMain cannot be executed
Asked Answered
R

3

4

I'm just trying to test a HelloWorld with KOtlin Multiplatform. I did it as described with the wizard. I can run the Android app and it works, but when I try to run the desktop main I get this error message.

   Cannot locate tasks that match ':composeApp:compileJava' as task 'compileJava' is ambiguous in project ':composeApp'. Candidates are: 'compileDebugAndroidTestJavaWithJavac', 'compileDebugJavaWithJavac', 'compileDebugUnitTestJavaWithJavac', 'compileReleaseJavaWithJavac', 'compileReleaseUnitTestJavaWithJavac'.
* Try:
> Run gradle tasks to get a list of available tasks.
> For more on name expansion, please refer to https://docs.gradle.org/8.4/userguide/command_line_interface.html#sec:name_abbreviation in the Gradle documentation.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.4/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 883ms

i also tried already the command gradle :composeApp:run or gradlew tasks but that doesn't work either, I get this error message:

gradlew : The name "gradlew" was not recognized as the name of a cmdlet, a function, a script file or an executable program. Check the spelling of the 
name, or whether the path is correct (if included), and repeat the process.
In line:1 Character:1
+ gradlew tasks
+ ~~~~~~~
    + CategoryInfo : ObjectNotFound: (gradlew:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Remonstrate answered 14/11, 2023 at 12:10 Comment(0)
O
11

This same problem happened to me in a project with Kotlin Multiplatform on Windows 11.

enter image description here

Execute from PowerShell in the root path of the project the command

.\gradlew :composeApp:run

enter image description here

And for a better execution from Android Studio go to "Edit Configuration" of the gradle and set the command "composeApp:run" and the name of this new configuration.

enter image description here enter image description here

I hope my answer has been helpful

Openminded answered 22/1, 2024 at 2:56 Comment(0)
K
2

Since gradle wasn't setup for me in windows (for android studio as default), it may be quicker/simpler to use:

.\gradlew :composeApp:run

(in android studio terminal in the project directory)

Knar answered 20/12, 2023 at 12:2 Comment(0)
R
0

I've got it out for everyone who uses Windows. Before I simply wrote this command in the terminal and got the error message.

Now I wrote the command gradle :composeApp:run in Run Anything (opens with 2*strg) and it works.

Remonstrate answered 14/11, 2023 at 12:25 Comment(1)
For those who don't speak German, "strg" is the CTRL key.Papillon

© 2022 - 2025 — McMap. All rights reserved.