Hi all, I have a question regarding creating kotli...
# getting-started
a
Hi all, I have a question regarding creating kotlin library. I want to wrap already created javascript library (available on npm) in a kotlin library and consume it in android native projects. How can i do so? please anyone help on this? Thank You
e
That is impossible.
a
Hi @efemoney, do you know any other way to achieve it?
p
You will have to add a JavaScript engine into your code. The other alternative, it depends on your requirements, is using a WebView, there is an API to call functions from kotlin/java to the JavaScript code running in the WebView. Take a look into the Cordova project. Back to the engine alternative, you can check https://github.com/cashapp/zipline, Check what they do.
1
But yeah any path is a heavy alternative if you just want to execute one library code. I believe it would be much easier trying to find the kotlin version of that library.
a
@Pablichjenkov I will check the zipline and cordova github repos. Thank You
p
Those are big projects, for the case you plan to run a full JavaScript app or something of that magnitude. But again, for one single use library it would be easier just finding the kotlin equivalent of that library.
a
ok got it.
j
Or the java equivalent, which you could use from Kotlin
1
What library did you have in mind specifically? What did you intend to do with it?
a
not any specific js lib
y
You could also, as long as the library isn't js-specific, try to rewrite the library in Kotlin. It's quite a difficult undertaking, but it could be easier if there's typescript definitions for the library already
j
@arunshaik432 I thought your question was about a library you wanted to use. Was it just a theoretical question without a concrete need?
a
i need it in one my contract work. they want me to build a kotlin wrapper on top of their crypto js library that kotlin lib will be used in android native projects. that is why i asked this question