Hi, how to add a lib which is written via kotlin to the project?

52 views
Skip to first unread message

Albert Gao

unread,
Oct 8, 2017, 8:24:00 PM10/8/17
to CodenameOne Discussions
IDE: IDEA
Desktop: Mac OS
Simulator
Device

I managed to add the kotlin support and get it running via this repo `https://github.com/shannah/codenameone-kotlin`
And it's easy to use and update the runtime

However, we have some libs which is written purely on kotlin and based on kotlin.coroutine and kotlin.reflection, how to add those libs to the projects? Thanks :)

Shai Almog

unread,
Oct 9, 2017, 12:37:54 AM10/9/17
to CodenameOne Discussions
I'm not really sure about that. I think they can be wrapped in a cn1lib just like other Codename One code and should work fine. Notice what Steve wrote in the post in a response to a similar question: http://disq.us/p/1kg8b6h

Albert Gao

unread,
Oct 9, 2017, 10:53:21 PM10/9/17
to CodenameOne Discussions
Thanks, saw that reply, could you please provide a link to some detail of the cn1lib and how to generate and consume them?

Albert Gao

unread,
Oct 10, 2017, 12:32:22 AM10/10/17
to CodenameOne Discussions
Found the doc on the developer guide, will learn :)

Shai Almog

unread,
Oct 10, 2017, 12:36:38 AM10/10/17
to CodenameOne Discussions
When you create a new project you are given an option to generate a cn1lib. It's technically a zip file that allows you to embed OS native code and provides some helper features like source hints for completion. There is a section on this in the developer guide, it's pretty much like a JAR.
You can place a cn1lib in the lib directory of your project then use "refresh cn1libs" in the right click menu to install them. Most cn1libs are open source so you can check their code.

Steve Hannah

unread,
Oct 10, 2017, 1:18:46 PM10/10/17
to codenameone...@googlegroups.com
As Shai mentioned, you should be able to create CN1libs with kotlin code.  The two libraries that you mention (coroutines and reflection) are very likely to give you trouble though, since CN1 doesn't support reflection - and the coroutines lib does things that was "low-level" enough that portions of it needed to be implemented separately for Swing and JavaFX - i.e. for coroutines, at the very least you'll probably have to implement a "bridge" layer yourself.  It won't "just work".




On Mon, Oct 9, 2017 at 9:36 PM, Shai Almog <shai....@gmail.com> wrote:
When you create a new project you are given an option to generate a cn1lib. It's technically a zip file that allows you to embed OS native code and provides some helper features like source hints for completion. There is a section on this in the developer guide, it's pretty much like a JAR.
You can place a cn1lib in the lib directory of your project then use "refresh cn1libs" in the right click menu to install them. Most cn1libs are open source so you can check their code.

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discussions+unsub...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/43d65700-f99a-4626-aead-051f78b6dacb%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Steve Hannah
Software Developer
Codename One

Albert Gao

unread,
Oct 11, 2017, 12:19:33 AM10/11/17
to CodenameOne Discussions
Wow, this is one of the most responsive teams I've ever seen, really appreciate that!
Thanks for the hints, sounds like I should use more CN1 way to do this :)
Reply all
Reply to author
Forward
0 new messages