How to use the kotlin compiler in command line which comes with Android Studio?

Viewed 1493

I have Android studio version 3.4.1. I am able to build Android apps with the Kotlin language. I have heard that we can use Kotlin for creating standalone programs other than building android apps.

So, I want to know how to run the Kotlin compiler of Android studio to compile and run Kotlin programs in the command line, without downloading anything else?. I am using Windows 10 Pro.

1 Answers

I'm on Lubuntu 16.04 LTS, not Windows. But maybe this can still help you.

In my Lubuntu, Android Studio put the Kotlin compiler in directory $HOME/.AndroidStudio3.4/config/plugins/Kotlin/kotlinc/bin .

So on Windows, make your file manager show hidden files and directories - because on Lubuntu, the "." in ".AndroidStudio3.4" means "hidden".

Go to your home or user directory and find a directory named "AndroidStudio3.4" or similar. Then just follow the path given above.

On Lubuntu, kotlinc (the compiler) isn't executable. If it's the same on Windows, give it execution permission.

I can't imagine that giving this permission affects how Kotlin works in Android Studio. But if you want to be on the safe side, install a separate command line compiler or IntelliJ.

By the way, the Kotlin 1.3.40 REPL crashes (s. issue KT-32085). If you need it, use Kotlin 1.3.31 .

Related