35

I'm trying to use the Kotlin REPL within Android Studio.
However, when I open it, I get the following output:

"E:\Program Files\Android\Arctic Fox\android-studio\jre\bin\java.exe" -Dkotlin.repl.ideMode=true -Dfile.encoding=UTF-8 -classpath "E:\Program Files\Android\Arctic Fox\android-studio\lib\idea_rt.jar;C:\Users\me\AppData\Local\Temp\classpath901685403.jar" com.intellij.rt.execution.CommandLineWrapper C:\Users\me\AppData\Local\Temp\classpath901685403.jar org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
`CommandLineWrapper` is ill-suited for launching apps on Java 9+.
If the run configuration uses "classpath file", please change it to "@argfile".
Otherwise, please contact support.

Process finished with exit code 1

The closest solution I've been able to find is this one:
Test framework quit unexpectedly - ClassNotFound Exception
which suggests changing a value in the run configuration, however there doesn't seem to be a run configuration avalible for the REPL.

There is one for "Java Scratch", however changing this does not solve the issue.

I'm using the Arctic Fox Beta (2020.3.1 Beta 5), with version 203-1.5.20-release-289-AS7717.8 of the Kotlin plugin.

2
  • 4
    I have the same issue, for some reason if i start REPL again after it failed (without closing the failed REPL), it now asks for a context module and works. If I open it again, it works. If I close it, then open it again, it fails.
    – Joozd
    Sep 25, 2021 at 9:39
  • comment from @Joozd is the only way for me to get the repl to work. IntelliJ IDEA 2022.3.2 (Community Edition)
    – LXJ
    Feb 8 at 7:58

4 Answers 4

43

Keeping the REPL window displaying the above error, again select Tools > Kotlin > Kotlin REPL

A choice is displayed with two items (Project) (Project).app

Select the first option with the name of your project and the REPL starts working.

error message

option after selecting Kotlin REPL again

correctly running REPL

2
  • this worked for me with Android Studio Bumblebee | 2021.1.1 Patch 2 Build #AI-211.7628.21.2111.8193401, built on February 17, 2022
    – or_dvir
    Mar 16, 2022 at 11:01
  • Worked on Android Studio Dolphin | 2021.3.1 as well
    – SMagic
    Sep 20, 2022 at 6:49
17

I changed Run > Edit Configurations... > Templates > Java Scratch > Shorten command line to @argfile (Java 9+) and it fixes the issue.

Android Studio Arctic Fox | 2020.3.1 Build #AI-203.7717.56.2031.7583922, built on July 26, 2021 Runtime version: 11.0.10+0-b96-7249189 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

4
  • 2
    This doesn't work for me. I have Android Studio Arctic Fox 2020.3.1 Patch 3. Jan 3, 2022 at 13:10
  • 1
    Worked for me in Bumblebee 2021.1.1: Run>Edit Configurations...>Edit configuration templates...>Java Scratch>Shorten command line:>@argfile (Java 9+)
    – Phil
    Jan 31, 2022 at 1:06
  • If the steps mentioned in the answer don't work then in the Java Scratch file look for classPath Module and click one of the modules( YOUPROJECTNAME, YOURPROJECTNAME.APP) and then select the @argfile(Java9+) shorten command line for that module . And when you open the REPL choose the module which you selected before when changed its short command line Feb 9, 2022 at 15:12
  • I really hoped that this work for me, but it didn't unfortunately: /usr/lib/jvm/java-11-openjdk-amd64/bin/java -Dkotlin.repl.ideMode=true -Dfile.encoding=UTF-8 -classpath /home/xxx/android-studio/lib/idea_rt.jar:/tmp/classpath1056675736.jar com.intellij.rt.execution.CommandLineWrapper /tmp/classpath1056675736.jar org.jetbrains.kotlin.cli.jvm.K2JVMCompiler CommandLineWrapper is ill-suited for launching apps on Java 9+. If the run configuration uses "classpath file", please change it to "@argfile". Otherwise, please contact support.
    – LXJ
    Mar 13, 2022 at 9:28
1

A temporary solution could be if you add the following expression to your gradle.properties file:

android.enableBuildCache=false

After that, Gradle sync (and maybe restarting your IDE) is needed of course.

0

I have the same error but eventually fixed it by invalidate caches / restart. Btw I'm using Android Studio Arctic Fox | 2020.3.1 RC 1 and Kotlin plugin version 203-1.5.20-release-289-AS7717.8

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.