How to use Kotlin compiler on Android


Hello! I want to use kotlin compiler in my app to compile .kt files. Is that possible? If so what library do I need.


Hey, I think you understood me wrong, I want to make my android app compile a .kt file like an IDE does


You can try packaging the Kotlin compiler as an Android app, and this could work, but there is no ready-made library that you can simply plug in into your app. Also note that the Kotlin compiler has fairly high CPU and memory requirements, which means that compiling even small files on old Android devices could take minutes.

I don’t know what problem you’re trying to solve, but I’m pretty sure that running the Kotlin compiler on the user’s phone is not the optimal way to do that.


@yole Thanks, I wasn’t going to make my app in the google play store anyway, its just for me, I thought since there are mobile apps that can compile java, c/c++ and even Python why not make one for kotlin, but I think its harder than I thought. Thanks though.