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.

@MohamedWS Did you manage to make it? I also have to compile runtime Kotlin code on Android, but kotlin-compiler dependency gives me several problems on compile time.
If you made it please show me how, thanks.

@MohamedWS Thank you so much for your response. Unfortunately the conditions (terminal simulator and root access) are not possible for my project. I will make it somehow.

@arabello yeah unfortunately since running kotlin compiler requires jre I had to transfer a script to /system/bin to get it to work

you can use jvdroid app availble in play store

it can compile and run kotlin code