Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin for a Cordova/Ionic based plugin

is it possible to use Kotlin as a framework/language as a Cordova plugin?

first issue is that it's not copying the .kt file, because it looks for *.java or *.xml

if so anyone know a reference on how to setup?

like image 875
Frendi Muhamad Avatar asked Dec 23 '22 03:12

Frendi Muhamad


1 Answers

Recently I've been working with Kotlin in Cordova plugins, but when I started out I also couldn't find any existing references as to how to create a Cordova plugin using Kotlin.

So I've created an example plugin which you can use as a template:
https://github.com/dpa99c/cordova-plugin-hello-kotlin

As you can see, the native part on the Cordova plugin interface is implemented in Kotlin.

Because currently cordova-android@7 doesn't implicitly support Kotlin, the plugin uses hook scripts to set up the native Android project created by Cordova for Kotlin, and also to remove .kt files from the platform project when the plugin is uninstalled, since currently cordova-android@7 only does this for .java files.

But it works and you can try it out with the test app project.

like image 85
DaveAlden Avatar answered Jan 02 '23 15:01

DaveAlden